@SuppressWarnings("unchecked")
 private <T> void convertToJson(Iterable<T> items, JSONArray results) throws JSONException {
   for (T resultObject : items) {
     if (resultObject instanceof Element) {
       results.put(GraphSONUtility.jsonFromElement((Element) resultObject, null, graphsonMode));
     } else if (resultObject instanceof List) {
       convertToJson((Iterable<T>) resultObject, results);
     }
   }
 }
  public Vertex deserializeVertex(Graph graph, JsonObject vertexJson) throws IOException {
    Vertex vertex;
    try {
      GraphElementFactory factory = new GraphElementFactory(graph);
      vertex = GraphSONUtility.vertexFromJson(vertexJson.toString(), factory, graphsonMode, null);
    } finally {
    }

    return vertex;
  }
  public <T extends Element> JsonObject serializeElement(T element) throws IOException {
    JSONObject elementJson;
    try {
      elementJson = GraphSONUtility.jsonFromElement(element, null, graphsonMode);
    } catch (JSONException e) {
      throw new IOException(e);
    } finally {
    }

    return new JsonObject(elementJson.toString());
  }
  public Edge deserializeEdge(Graph graph, Vertex inVertex, Vertex outVertex, JsonObject edgeJson)
      throws IOException {
    Edge edge;
    try {
      GraphElementFactory factory = new GraphElementFactory(graph);
      edge =
          GraphSONUtility.edgeFromJson(
              edgeJson.toString(), inVertex, outVertex, factory, graphsonMode, null);
    } finally {
    }

    return edge;
  }