I have a api like this
-{
- meta {
item1: value;
item2: value;
item3: value;
},
- object [
{
- category {
id: 1;
...
}
- File {
...
}
},
{
- category {
id:2;
...
}
- File {
...
}
}
]
I dont have any problem to parse JSONArray of "obejct" and it's JSONObjects... I do like this:
private static final String TAG_NOD = "object";
private static final String TAG_CAT = "category";
private static final String TAG_CAT_ID = "id";
private static final String TAG_CAT = "File";
JSONArray Items = null;
JSONObject jsonObj = new JSONObject(jsonstr); // jsonstr is loaded url by httpcal
Items = jsonObj.getJSONArray(TAG_NOD);
for ( int i=0; i<Items.length(); i++){
JSONObject childs = Items.getJSONObject(i);
JSONObject category= child.getJSONOBject(TAG_CAT);
// getting category items in string like String ID = category.getString(TAG_CAT_ID);
JSONObject file = Item.getJSONObject(TAG_FILE)
// getting file items in string like file.getString(String name)
HashMap<String, String> items = new HashMap<String, String>();
items.put(TAG_CAT_ID, ID);
.
.
.
ItemLis.add(items); //Itemlist is a ArrayList<HashMap<String, String>>()
}
but my problem is to parsing jsonobject of "meta" and add its data to my ListItem Arraylist any solution appreciated :D
JSONObject json_meta = jsonObj.getJSONObject("meta");to get meta JSONObject from JSONObject