如何在不知道名称的情况下解析JSONObject?

时间:2015-07-01 10:07:21

标签: java android json

我有这样的json字符串:

some/route/{platform}/{country}/

如何在不知道名称“2”的情况下解析JSONObject 刚搬到下一个阵列?

1 个答案:

答案 0 :(得分:4)

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.....
    }
}