I have following JSON as response from my server. At first, I thought, it was invalid JSON but after validating it, it seems to be correct:
JOSN: {
\"cat
But how do I parse the JSON I have here?
if keys inside category
JSONObject is dynamic then use JSONObject.keys()
to get Iterator
for getting values as:
JSONObject mainJSONObj=new JSONObject();
// get category JSONObject from mainJSONObj
JSONObject categoryJSONObj=mainJSONObj.getJSONObject("category");
// get all keys from categoryJSONObj
Iterator iterator = categoryJSONObj.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Log.i("TAG","key:"+key +"--Value::"+categoryJSONObj.optString(key);
}