JSONParser { public JSONArray parseJSONArray(JSONObject object, String name) { try { return object.getJSONArray(name); } catch (JSONException e) { if (DEBUG) Log.e(TAG, "no json array for " + name, e); return null; } }  String parseString(JSONObject object, String name); long parseLong(JSONObject object, String name); boolean parseBoolean(JSONObject object, String name); JSONObject parseJSONObject(JSONObject object, String name); JSONArray parseJSONArray(JSONObject object, String name);  }
@Test public void test_parseJSONArray() throws Exception { JSONObject object = new JSONObject(); JSONArray innerArray = new JSONArray(); object.put("test", innerArray); assertEquals(innerArray, parser.parseJSONArray(object, "test")); }
@Test public void test_parseJSONArray_null() throws Exception { JSONObject object = new JSONObject(); JSONArray innerArray = new JSONArray(); object.put("test", innerArray); assertEquals(null, parser.parseJSONArray(object, "not_valid")); }