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文字列を解析します。

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 に答える