【发布时间】:2018-06-02 20:16:51
【问题描述】:
以下是 JSON 链接
{
"AF": {
"country_name": "Afghanistan",
"dialling_code": "+93"
},
"AL": {
"country_name": "Albania",
"dialling_code": "+355"
},
"DZ": {
"country_name": "Algeria",
"dialling_code": "+213"
},
从上面的 JSON 链接,我尝试使用下面的代码从 JSON 中检索数据。
try {
jsonObject = new JSONObject(JSON_STRING);
countryname = jsonObject.getString("country_name");
dialingcode = jsonObject.getString("dialling_code");
Log.d("COUNTRYNAME", countryname);
Log.d("DIALER_CODE", dialingcode);
} catch (JSONException e1) {
e1.printStackTrace();
}
【问题讨论】:
标签: android json web-services