0

我有如下给出的 JSON 数组。如何根据其键获取值?

$> 

[{Work
> Group=[{"id":"wNUvBiv5tQDFphP3zITN5NDEqyXJM8W2","errRsn":["Response
> time from Sweden exceeded 1500 ms."],"ap":"100.0
> %","status":"Trouble","name":"xxxx","rsptime":"1549
> ms","downs":"0","tDwn":"5 Hrs 50 Mins
> ","conf":"no","mtype":"URL","monitorid":"2c2d1ba5b57d9c1be8fcae5522b5bb9f","lsDur":"-","lsDwn":""},{"id":"wNUvBiv5tQB1kKQSZBij\/b8FU++kkoRh","ap":"100.0
> %","status":"Up","name":"xxx","rsptime":"424
> ms","downs":"0","conf":"no","mtype":"HOMEPAGE","monitorid":"58e79381158d85e8eb944ec5506db09a","lsDur":"-"},{"id":"wNUvBiv5tQD\/DIkhHWufnTRJzbcIgZk4","rspvalue":"-","downReason":"Unknown
> Host","status":"Down","name":"xxxx","tDwn":"62 days 17 Hrs 7 Mins
> ","conf":"yes","mtype":"PORT","monitorid":"6cacfbf47ad21d824006be1168efc3c6","lsDwn":"2012-09-18"},{"id":"wNUvBiv5tQCBw1RAuk0Q2P1FZPxXxMr1","downReason":"Trouble"

天 0 小时 0 分钟 ","lsDwn":"2012-06-21"}]}]

4

1 回答 1

3

使用以下代码解析您的 json String :

JSONArray jarray = new JSONArray("Your JSON String Here");

for (int i=0; i < jarray.length(); i++)
{
  JSONObject oneObject = jArray.getJSONObject(i);
  // Pulling items from the array
   String oneObjectsid = oneObject.getString("id");
   String oneObjectsap = oneObject.getString("ap");
   String oneObjectsstatus = oneObject.getString("status");
   String oneObjectsname = oneObject.getString("name");
   //your rest code here...
}
于 2012-11-20T06:30:49.677 回答