有人可以帮助指导我如何将 JSONArray 解析为 TextViews 吗?到目前为止,每次我解析它时,它只显示最后的结果,而不是一切。
到目前为止,我有:
try {
standby_position = json.getString("standby_position");
zone_name = json.getString("zone_name");
zone_no = json.getString("zone_no");
status = json.getString("status");
JSONArray standby_list = json.getJSONArray("standby_list");
for (int i1 = 0; i1 < standby_list.length(); i1++) {
JSONObject c = standby_list.getJSONObject(i1);
DRIVER = c.getString(driver);
SINCE = c.getString(since);
WAITING = c.getString(waiting);
GPS_DATA = c.getString(gps_data);
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
我试图做:
TextView information = (TextView) findViewById(R.id.information);
information.setText ( DRIVER + SINCE + WAITING );
这是我要解析的内容:
{
"driver": "819",
"gps_data": "1",
"last_geocode": "",
"lastLatitudeUpdate": "12/31/1969 5:00:00 PM",
"standby_position": "1",
"zone_name": "STK",
"zone_no": "STK",
"status": "Your are checked-in and currently #1 STK. (as of: 7/19/2012 1:50:02 PM)",
"standby_list": [
{
"driver": "291",
"since": "12:33:00 PM",
"waiting": "77",
"gps_data": "0"
},
{
"driver": "103",
"since": "12:49:21 PM",
"waiting": "61",
"gps_data": "0"
},
{
"driver": "287",
"since": "12:51:00 PM",
"waiting": "59",
"gps_data": "0"
},
{
"driver": "271",
"since": "1:22:00 PM",
"waiting": "28",
"gps_data": "0"
},
{
"driver": "819",
"since": "8:58:36 AM",
"waiting": "292",
"gps_data": "1"
}
]
}
当我这样做时,将显示唯一的最后一个解析 Json。有任何想法吗?