I have JSON File as below which has to be dumped into an ArrayList:
{ \"main1\" : [ { \"child1\" : valueA, \"child2\" : valueB, \"child3\" : va
getJSONObject("child2");
Will throw an exception if child2 does not exist. Try this instead:
getchild2 = jArray.getJSONObject(j).optJSONObject("child2");
That way you don't have to catch an exception if child2 doesn't exist and can instead check for null.