[英]JSON Array parsing element by element
I have a JSON array like this: 我有一个像这样的JSON数组:
[
{
"stats": {
"callQuality": 5,
"audioRecvRemoteMute": false,
"audioRecvLocalMute": true,
},
"rtpStatsList": [
{
"media": 1,
"direction": 1,
"content": true,
}
],
"timestamp": 1460208299000
},
{
"stats": {
"callQuality": 5,
"audioRecvRemoteMute": false,
"audioRecvLocalMute": true,
},
"rtpStatsList": [
{
"media": 1,
"direction": 1,
"content": true,
}
],
"timestamp": 1460208299000
},
]
There are multiple elements (180 elements for eg) in the array. 数组中有多个元素(例如180个元素)。 I need "media" and "direction" parameters under rtpStatsList.
我需要rtpStatsList下的“ media”和“ direction”参数。 Any useful suggestion to parse the same using JAVA?
使用Java解析相同内容有什么有用的建议吗?
Here Check this out 在这里检查一下
String data = EntityUtils.toString(httpResponse2.getEntity());
JSONArray js=new JSONArray(data)
for(int i=0;i<js.length();i++) {
JSONArray js=new JSONArray(data)
for(int i=0;i<js.length();i++) {
JSONObject total = js.getJSONObject(js);{
JSONArray rtpStatsList=total.getJSONArray("rtpStatsList");
JSONObject total = js.getJSONObject(js);{
JSONArray rtpStatsList=total.getJSONArray("rtpStatsList");
for(int j=0;j<rtpStatsList.length();j++) {
`JSONObject jsonObject = rtpStatsList.getJSONObject(j);`
media = jsonObject.getString("media");
direction = jsonObject.getString("direction");
}
}`
Use this: http://theoryapp.com/parse-json-in-java/ You have an extensive explanation of: 使用此方法: http : //theoryapp.com/parse-json-in-java/您对以下内容有广泛的解释:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.