当返回值为json字符串时 如何获得其中的json数组

时间:2023-03-08 17:23:30
当返回值为json字符串时   如何获得其中的json数组

  

  json数据格式

{"IPPORT":"当返回值为json字符串时   如何获得其中的json数组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");  
        }  
    }