### Question:
QueryUtil { public static ArrayList toList(JSONArray array) throws JSONException { ArrayList list = new ArrayList(); for (int i = 0; i < array.length(); i++) { list.add(fromJson(array.get(i))); } return list; } private  QueryUtil(); static JSONObject extractAggregationValue(SearchResponse response); static ArrayList toList(JSONArray array); static Map<String, Object> toMap(JSONObject object); static JSONObject extractAggregationStr(String response);  }### Answer:
@Test public void toList() { JSONArray arr = new JSONArray(); JSONObject obj = new JSONObject(); obj.put("aggregations", "{\n" + "\"count\":{\n" + "\"value\" : 0.0\n" + "}\n" + "}"); obj.put("gender", "g_f"); obj.put("name", "obj"); JSONObject obj2 = new JSONObject(); obj2.put("gender", "g_f"); obj2.put("name", "obj2"); JSONObject obj3 = new JSONObject(); obj3.put("aggregations", "{\n" + "\"count\":{\n" + "\"value\" : 3.0\n" + "}\n" + "}"); obj3.put("gender", "g_n"); obj3.put("name", "obj3"); arr.put(obj); arr.put(obj2); arr.put(obj3); List res = QueryUtil.toList(arr); assertNotNull(res); assertEquals(3, res.size(), 0); assertEquals("{gender=g_f, name=obj2}", res.get(1).toString()); }