使用JSONObject
keys()获取密钥,然后迭代每个密钥以获取动态值。
代码大致如下所示:
// searchResult refers to the current element in the array "search_result" JSonObject questionMark = searchResult.getJSonObject("question_mark"); Iterator keys = questionMark.keys(); while(keys.hasNext()) { // loop to get the dynamic key String currentDynamicKey = (String)keys.next(); // get the value of the dynamic key JSonObject currentDynamicValue = questionMark.getJSonObject(currentDynamicKey); // do something here with the value... }


