protected MyJSONObject.Array _process(List<Entity> entities, MetaClass metaClass, View view) throws Exception { MyJSONObject.Array result = new MyJSONObject.Array(); for (Entity entity : entities) { MyJSON item = encodeInstance(entity, new HashSet<Entity>(), metaClass, view); result.add(item); } return result; }
public String toString() { return asString(0).toString(); }
MyJSONObject.Array array = new MyJSONObject.Array(); Arrays.stream(filteredAttributes).forEach(obj -> array.add("\"" + obj + "\"")); MyJSONObject.Array array = new MyJSONObject.Array(); root.set(property.getName(), array); for (Object o : members) { if (o == null) { array.add(null); } else { array.add(encodeInstance((Entity) o, visited, property.getRange().asClass(), propertyView));
public static void main(String[] args) throws Exception { MyJSONObject o = new MyJSONObject("Person-1234", false); MyJSONObject r = new MyJSONObject("Person-1234", true); MyJSONObject f = new MyJSONObject("Person-2345", false); Array a = new Array(); a.add(f); a.add(3456); a.add(null); a.add(r); a.add(null); KVMap map = new KVMap(); map.put("k1", r); map.put("k2", f); map.put("k3", null); map.put("k4", 3456); map.put(null, 6789); f.set("name", "Mary"); f.set("age", 30); f.set("friend", r); o.set("name", "John"); o.set("age", 20); o.set("friend", f); o.set("friends", a); o.set("map", map); System.err.println(o); } }
@Override public String process(Set<Entity> entities) throws Exception { MyJSONObject.Array result = new MyJSONObject.Array(); for (Entity entity : entities) { MyJSONObject entityJson = encodeInstance(entity, new HashSet<Entity>(), getMetaClass(entity), null); if (restConfig.getRestApiVersion() == 1) { //return map for old version of rest api MyJSONObject valueJson = encodeInstance(entity, new HashSet<Entity>(), getMetaClass(entity), null); MyJSONObject.Array mapping = new MyJSONObject.Array(); mapping.add(entityJson); mapping.add(valueJson); result.add(mapping); } else { result.add(entityJson); } } return result.toString(); }
@Override public String process(List<Entity> entities, MetaClass metaClass, View view) throws Exception { MyJSONObject.Array array = _process(entities, metaClass, view); return array.toString(); }