我有这样的json字符串:
{
"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
}
}Run Code Online (Sandbox Code Playgroud)
如何在不知道名称“2”的情况下解析 JSONObject 只是移动到下一个数组?
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.....
}
}
Run Code Online (Sandbox Code Playgroud)