首页 > 代码库 > 当返回值为json字符串时 如何获得其中的json数组
当返回值为json字符串时 如何获得其中的json数组
json数据格式
{"IPPORT":"192.168.0.12","time":"2017-04-05 09:12:06","oper":"01","data":[{"paramUnit":"℃","name":"1","data":"3 1.7"},{"paramUnit":"℃","name":"2","data":"57.3"},{"paramUnit":"%","name":"3","data":"3 1.7"},{"paramUnit":"%","name":"4","data":"46.5"},{"paramUnit":"lux","name":"14","data":"40050"},{"paramUnit":"ppm","name":"9","data":"70064"},{"paramUnit":"方西","name":"12","data":"8"},{"paramUnit":"mps","name":"11","data":"**"},{"paramUnit":"mm","name":"13","data":"*****"}],"equipmentId":"A13922016031464"}
wang就是json字符串 data是json数组
JSONObject jsonObject = new JSONObject(wang);
JsonArray datas = jsonObject..getJSONArray("data");
for (int i = 0; i < datas.length; i++) {
JsonObject jsonObject = datas.getJSONObject(i);
String childName = jsonObject.getString("data");
}
}
当返回值为json字符串时 如何获得其中的json数组
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。