my json string is here
{
"user": {"id": "S5675","name": "soman"},
"main": {"class1": { "modules": ["1","2"],
"subjects": { "english": {"type": "english","module_id": "1"},
"hindi": {"type": "hindi", "module_id": "2",}}},
"class2": {"modules": ["2","3"],
"subjects": {"english": {"type": "english","module_id": "2"},
"hindi": {"type": "urdu", "module_id": "3",}}}}}
I want to extract class1,class2 and its corresponding subjects . Here for class1 - english and hindi. and for class2 - english and urdu. I have tried like below
JSONObject subObj = json.getJSONObject("main"); //get class1 and class2
Iterator<String> keys=subObj.keys();
while(keys.hasNext()){
String key=keys.next();
Log.i("key","" + key);
}
I get class1 and class2. But how to extract corresponding subjects from above json. please suggest