json数据:
{
"code": "0",
"data": {
"channels": [
{
"channelId": 0,
"onLine": "1"
},
{
"channelId": 1,
"onLine": "1"
},
{
"channelId": 2,
"onLine": "1"
},
{
"channelId": 3,
"onLine": "1"
}
],
"deviceId": "3B03FCEPBQFS79Z",
"onLine": "1"
},
"msg": "操作成功。"
}
JSONObject js = (JSONObject) json.get("data");
JSONArray channels = js.getJSONArray("channels");
JSONObject item ;
for (int i =0; i<channels.size();i++){
item = channels.getJSONObject(i);
item.getString("channels");
item.getString("onLine");
}