如何在不知道名称的情况下解析JSONObject? [英] How can I parse JSONObject without knowing the name?
本文介绍了如何在不知道名称的情况下解析JSONObject?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的json字符串:
I have json string like this:
{
"2":{
"id":"2",
"first":"3",
"last":"2",
"ilike":"1",
"created_at":"2015-06-30 16:57:39",
"liketo":"2",
"firstname":"FirstName",
"lastname":"LastName",
"birthday":null
}
}
如何解析JSONObject而不知道名称2
只是移动到下一个数组?
How can I parse JSONObject without knowing the name "2" just moving to the next array?
推荐答案
String json="" // place your json format here in double Quotes with proper escapes .......
jObject = new JSONObject(json.trim());
Iterator<?> keys = jObject.keys();
while( keys.hasNext() ) {
String key = (String)keys.next();
if ( jObject.get(key) instanceof JSONObject ) {
// do what ever you want with the JSONObject.....
}
}
这篇关于如何在不知道名称的情况下解析JSONObject?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文