I want to get the value from below json response. I am able to get the value from first key but not anther key object. I want to get the value of all url but no of url is dynamic and key too. Below is json response:
I am able to get the value of body, title and created_date
{
"17": {
"27": {
"url": "some text here 1"
},
"28": {
"url": "some text here 12"
},
"29": {
"url": "some text here 123"
},
"title": "some text goes here",
"body": "Some text goes here",
"created_date": "1395386881"
}
}
Code what i am trying is below:
try {
json = new JSONTokener(jsonNewsResponse).nextValue();
if (json instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) json;
Iterator<?> keys = jsonObject.keys();
while (keys.hasNext()) {
nid = String.valueOf(keys.next());
JSONObject jsonObj = jsonObject.getJSONObject(nid);
attributeValue = jsonObj.getString(attributeName);
List<String> listitems = new ArrayList<String>();
Iterator<?> key = jsonObj.keys();
while (key.hasNext()) {
String fid = String.valueOf(key.next());
System.out.println("FID"+fid);
System.out.println("FID"+fid);
System.out.println("FID"+fid);
System.out.println("FID"+fid);
JSONObject jObject = jsonObj.getJSONObject(fid);
listitems.add(jObject.getString("url"));
}
attachments = listitems.toArray(new String[0]);
}
}