JsonArray和JsonObject遍历方法
一 .遍历JsonObject
JSONObject jsonObject = JSONObject.fromObject(string);
Iterator iterator = jsonObject.keys();
while(iterator.hasNext()){
String key = (String) iterator.next().toString();
while("BpsDataPerInterval".equals(key)) {
String string2 = jsonObject.getString(key);
二。遍历JsonArray
List<Map> array = JSONObject.fromObject(string2).getJSONArray("DataModule");
//每天最大
List<String> list3 = new ArrayList<String>();
if(array.size()>0){
array.forEach(a ->{
list3.add(a.get("Value").toString());
});
list2.add(Collections.max(list3));
}else{
list2.add("0");
}
break;
}
}
浙公网安备 33010602011771号