Parse JSON data using JSONReader or JSONObject/JSONArray
GSON is the easiest way when you have to work with nested objects.
like this:
//after the fetched Json:
Gson gson = new Gson();
Event[] events = gson.fromJson(yourJson, Event[].class);
//somewhere nested in the class:
static class Event{
int id;
String categoryName;
String categoryImage;
boolean hassubcategories;
ArrayList<Event> subcategories;
}
You can check this tutorial, http://androidsmith.com/2011/07/using-gson-to-parse-json-on-android/ or http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html or http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
You can use JSON Object/ JSON Array only if the size of your json data is less than 1MB. Else you should go with JSONReader. JSONReader actually use streaming approach while JSONObject and JSONArray eventually load all the data on RAM at once which causes OutOfMemoryException in case of bigger json.