@Test public void testJSONObjectTypeAdapter() throws Exception { JSONObject jsonObject = new JSONObject(); jsonObject.put("key", "value"); jsonObject.put("key1", "value1"); jsonObject.put("key2", "value2"); Gson gson = new Gson(); TypeAdapter<JSONObject> jsonObjectTypeAdapter = BatchingTypeAdapters.getJSONObjectTypeAdapter(gson); String toJson = jsonObjectTypeAdapter.toJson(jsonObject); JSONObject jsonObject1 = jsonObjectTypeAdapter.fromJson(toJson); Assert.assertTrue(jsonObject1.toString().equals(jsonObject.toString())); }
public static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson) { if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = new JSONObjectTypeAdapter(gson); } return jsonObjectTypeAdapter; }
BatchingTypeAdapters { public static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson) { if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = new JSONObjectTypeAdapter(gson); } return jsonObjectTypeAdapter; } }
BatchingTypeAdapters { public static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson) { if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = new JSONObjectTypeAdapter(gson); } return jsonObjectTypeAdapter; }  }
BatchingTypeAdapters { public static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson) { if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = new JSONObjectTypeAdapter(gson); } return jsonObjectTypeAdapter; }  static TypeAdapter<JSONArray> getJSONArrayTypeAdapter(Gson gson); static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson); }
BatchingTypeAdapters { public static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson) { if (jsonObjectTypeAdapter == null) { jsonObjectTypeAdapter = new JSONObjectTypeAdapter(gson); } return jsonObjectTypeAdapter; }  static TypeAdapter<JSONArray> getJSONArrayTypeAdapter(Gson gson); static TypeAdapter<JSONObject> getJSONObjectTypeAdapter(Gson gson); static final TypeAdapter<Integer> INTEGER; static final TypeAdapter<Long> LONG; }