I'm trying to parse this JSON in my app, im not sure if its well structured or not but that's what Im getting from the api for now. I have no idea how to get the key"number" of each Jsonobject and how to parse an jsonobject of jsonobjects, any help on that
{
"response":"1",
"data":{
"1":{
"category_name":"first",
"image_url":""
},
"2":{
"category_name":"secondType",
"image_url":""
},
"3":{
"category_name":"Night",
"image_url":""
}
}
}
here's my try to parse it
if (isAdded() && getActivity() != null && response.getString("response").equals("1")) {
JSONObject jsonObject = response.getJSONObject("data");
for (int i = 0; i < jsonObject.length(); i++) {
CategoryLookBookModel lookBookModel = new CategoryLookBookModel();
lookBookModel.setCategory_name(jsonObject.get(""+i).getString("category_name"));
lookBookModel.setCategory_image(jsonArray.getJSONObject(i).getString("image_url"));
list.add(lookBookModel);
}