【发布时间】:2012-01-03 10:25:54
【问题描述】:
我在安卓系统中工作。我想解析我的 json 数据。
这是我的 json 数据:-
{
“响应”:{
"groups":[
{
"type":"nearby",
"name":"Nearby",
"items":[
{
"id":"4ed0c8f48231b9ef88fe5f09",
"name":"Banayan Tree School",
"contact":{
},
"location":{
"lat":26.857954980225713,
"lng":75.76602927296061,
"distance":510
},
"categories":[
{
"id":"4bf58dd8d48988d1a8941735",
"name":"General College & University",
"pluralName":"General Colleges & Universities",
"shortName":"Other - Education",
"icon":"https:\/\/foursquare.com\/img\/categories\/education\/default.png",
"parents":[
"Colleges & Universities"
],
"primary":true
}
],
"verified":false,
"stats":{
"checkinsCount":5,
"usersCount":4,
"tipCount":0
},
"hereNow":{
"count":0
}
}
]
}
]
} }
我想使用 icon 在 imageview 中显示图标。 请建议我如何获取此图标值以及如何在 imageview 中使用此图标 url。
提前谢谢你。
我正在尝试这个,但它仍然会产生错误:- 这是我的代码:- 但仍在创建错误:-
JSONArray groups= (JSONArray) jsonObj.getJSONObject("response").getJSONArray("groups");
int length=groups.length(); if (length > 0){ for (int i = 0; i
{
JSONObject group= (JSONObject) groups.get(i); JSONArray items =(JSONArray) group.getJSONArray("items");
for (int j = 0; j
{
JSONObject item = (JSONObject) items.get(j);
JSONObject iconobject=(JSONObject) item.getJSONObject("categories");//this is created error that JSON.typeMismatch
venue.icon=iconobject.getString("icon");
}}}}
【问题讨论】: