【发布时间】:2016-06-22 06:51:45
【问题描述】:
我有一个 json 链接,如果我们打开它,我会得到以下结果
{
"Status": "Success",
"All_Details": [{
"Types": "0",
"TotalPoints": "0",
"ExpiringToday": 0
}],
"First": [{
"id": "0",
"ImagePath": "http://first.example.png"
}],
"Second": [{
"id": "2",
"ImagePath": "http://second.example.png"
}],
"Third": [{
"id": "3",
"ImagePath": "http://third.example.png"
}],
}
我需要的是,我想动态获取所有关键名称,如状态、All_details、First 等。
我还想获取 All_details 和 First Array 中的数据。 我使用了以下方法
@Override
public void onResponse(JSONObject response) throws JSONException {
VolleyLog.d(TAG, "Home Central OnResponse: " + response);
String statusStr = response.getString("Status");
Log.d(TAG, "Status: " + statusStr);
if (statusStr.equalsIgnoreCase("Success")) {
Iterator iterator = response.keys();
while (iterator.hasNext()) {
String key = (String)iterator.next();
}
}
}
我将所有键名存储在 String 键中。但是我无法打开获取 JSON 数组中的值,例如。我需要使用 String(Key) 获取第一个和第二个数组中的值。我该怎么做。???
【问题讨论】:
标签: java android arrays json android-json