コード例 #1
0
 @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);
     }
   }
 }
コード例 #2
0
  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());
  }