void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
@NonNull @Override public String toFormattedString(@NonNull CrashReportData data, @NonNull ImmutableSet<ReportField> order, @NonNull String mainJoiner, @NonNull String subJoiner, boolean urlEncode) throws JSONException { final Map<String, Object> map = data.toMap(); final JSONStringer stringer = new JSONStringer().object(); for (ReportField field : order) { stringer.key(field.toString()).value(map.remove(field.toString())); } for (Map.Entry<String, Object> entry : map.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } return stringer.endObject().toString(); } },
private static void addToStringer(JSONStringer stringer, Object o) throws JSONException { if (o instanceof JSONObject) { stringer.object(); JSONObject object = (JSONObject) o; Iterator<String> keyIterator = object.keys(); ArrayList<String> keys = new ArrayList<>(); while (keyIterator.hasNext()) { keys.add(keyIterator.next()); } Collections.sort(keys); for (String key : keys) { stringer.key(key); addToStringer(stringer, object.opt(key)); } stringer.endObject(); return; } if (o instanceof JSONArray) { JSONArray array = (JSONArray) o; stringer.array(); for (int i = 0; i < array.length(); ++i) { addToStringer(stringer, array.get(i)); } stringer.endArray(); return; } stringer.value(o); }
json_out.endObject();
public static String buildJSON(Map<String, Object> params) { final JSONStringer stringer = new JSONStringer(); stringer.object(); for (Map.Entry<String, Object> param : params.entrySet()) { if (param.getKey() != null && !"".equals(param.getKey()) && param.getValue() != null && !"" .equals(param.getValue())) { stringer.key(param.getKey()).value(param.getValue()); } } return stringer.endObject().toString(); }
@NonNull private JSONStringer writeLog(JSONStringer writer, Log log) throws JSONException { writer.object(); log.write(writer); writer.endObject(); return writer; }
void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
void writeTo(JSONStringer stringer) throws JSONException { stringer.object(); for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) { stringer.key(entry.getKey()).value(entry.getValue()); } stringer.endObject(); }
public static void writeMap(JSONStringer writer, String key, Map<String, String> value) throws JSONException { if (value != null) { writer.key(key).object(); for (Map.Entry<String, String> property : value.entrySet()) { writer.key(property.getKey()).value(property.getValue()); } writer.endObject(); } }
JSONStringer json = new JSONStringer(); json.object(); json.key("stuff").value("1") .key("name").value("2") .key("type_name").value("3") .key("type").value("4"); json.endObject(); //after calling the method which returns a jsonobject like above: JSONObject jo=new JSONObject(json.toString()); jo.put("hi", "hi2");
public final String write(CE customizableEntity) { jsonWriter.object(); handleProperties(customizableEntity); for (Entry<String, Object> customFields : customizableEntity.getCustomFields()) { set(customFields.getKey(), customFields.getValue()); } jsonWriter.endObject(); return jsonWriter.toString(); }
public static String writeToJson(Form form) { JSONStringer js = new JSONStringer(); js.object(); List<Field> fields = new ArrayList<Field>(); collectVisibleFields(form, fields); fieldsToJson(js, fields); js.endObject(); return js.toString(); }
public static String writeToJson(Form form) { JSONStringer js = new JSONStringer(); js.object(); writeToJson(form, js); js.endObject(); return js.toString(); }
public static void writeArray(JSONStringer writer, String key, List<? extends Model> value) throws JSONException { if (value != null) { writer.key(key).array(); for (Model model : value) { writer.object(); model.write(writer); writer.endObject(); } writer.endArray(); } }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); if (getException() != null) { writer.key(EXCEPTION).object(); exception.write(writer); writer.endObject(); } JSONUtils.writeArray(writer, THREADS, getThreads()); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); writer.key(ID).value(getId()); if (getException() != null) { writer.key(EXCEPTION).object(); exception.write(writer); writer.endObject(); } }