日志文章

2021-9-8 aflfte2011

java获取json数组

String str={"id":["3","4","5","7","8","9","10","11","12","15","16","17"],"cid":["1","1","2","1","2","2","2","2","2","2","2","2"],"sjtype":["HW","GX","DL","GX","GX","GX","GX","GX","GX","GX","GX","GX"],"devid":["2","2","2","1","6","6","6","6","6","6","6","6"],"control":["j1","j2","j3","j1","j1","j2","j3","j4","j5","j6","j7","j8"],"compare":["0","2","0","0","0","0","0","0","0","0","0","0"],"data":["200","30","800","60","35","35","35","35","35","35","35","35"]};
JSONObject json=new JSONObject(str);
JSONObject json=new JSONObject(result);
JSONArray id=json.getJSONArray("id");
JSONArray sjtype=json.getJSONArray("sjtype");
JSONArray cid=json.getJSONArray("cid");
JSONArray devid=json.getJSONArray("devid");
JSONArray control=json.getJSONArray("control");
JSONArray compare=json.getJSONArray("compare");
JSONArray data=json.getJSONArray("data");
for(int i=0;i<id.length();i++) {
    System.out.println(id.getInt(i)+"\t"+cid.getInt(i)+"\t"+sjtype.getString(i)+"\t"+devid.getInt(i)+"\t"+control.getString(i)+"\t"+compare.getInt(i)+"\t"+data.getInt(i));
}

« debian安装jdk | ubuntu server cloud-init连接隐藏WiFi»