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