例如
"result": {
"ceshi": "測(cè)試",
"yingyu": "英語",
"hanyu": "中文",
"CANTONESE": "粵語"
}
JSONObject 提供了一個(gè)方法keys().
try {
JSONObject jsonObject = new JSONObject(jsonStr);
Iterator<String> keys = jsonObject.keys();
while (keys.hasNext()) {
String key = keys.next();
String value = jsonObject.optString(key);
Log.e("zmm", key + "--------->" + value);
}
} catch (JSONException e) {
e.printStackTrace();
}
解決