public <T> void appendList(String key, T[] list, JsonEncoder<T> encoder) throws JSONException { JSONArray array = new JSONArray(); object.put(key, array); for (T t : list) { JsonBuffer jsonBuffer = new JsonBuffer(); encoder.encode(t, jsonBuffer); array.put(jsonBuffer.getJsonObject()); } }
public <T> void appendList( String key, Iterable<T> list, JsonEncoder<T> encoder, Criteria<T> criteria) throws JSONException { JSONArray array = new JSONArray(); object.put(key, array); for (T t : list) { if (criteria != null) { if (criteria.isMeet(t)) { JsonBuffer jsonBuffer = new JsonBuffer(); encoder.encode(t, jsonBuffer); array.put(jsonBuffer.getJsonObject()); } } else { JsonBuffer jsonBuffer = new JsonBuffer(); encoder.encode(t, jsonBuffer); array.put(jsonBuffer.getJsonObject()); } } }
public <T> void appendObject(String key, T t, JsonEncoder<T> encoder) throws JSONException { JsonBuffer jsonBuffer = new JsonBuffer(); encoder.encode(t, jsonBuffer); object.put(key, jsonBuffer.getJsonObject()); }