我想去到result中的index對象應該怎麼取?
先取了result這個jsonArray 但是裡面還有個jsonArray啊?,不知道怎麼拿,求大神指導
{
"error": 0,
"status": "success",
"date": "2015-01-16",
"results": [
{
"currentCity": "惠州",
"pm25": "39",
"index": [
{
"title": "穿衣",
"zs": "較冷",
"tipt": "穿衣指數",
"des": "建議著大衣、呢外套加毛衣、衛衣等服裝。體弱者宜著厚外套、厚毛衣。因晝夜溫差較大,注意增減衣服。"
},
{
"title": "洗車",
"zs": "較適宜",
"tipt": "洗車指數",
"des": "較適宜洗車,未來一天無雨,風力較小,擦洗一新的汽車至少能保持一天。"
}
}
public class Bean{
private String currentCity;
private String pm25;
get和set方法
}
public static Bean getBean(){
//省略
if(json.has("results")){
JSONArray array = json.getjsonArray("result");
String arrayStr = array.toString();
Bean bean = new Bean();
Gson gson = new GsonBuilder().create();
bean = gson.fromJson(arrayStr,
new TypeToken<ArrayList<Bean>>() {
}.getType());
return bean;
}
}