首页 > 代码库 > jsonArray遍历 取出数组中对象
jsonArray遍历 取出数组中对象
字符串转JSONArray 然后遍历array
下载
Java代码
List<String> helpPersonList=new ArrayList<>();
List<String> oraList=new ArrayList<>();
String json="[{"aid":"aid-0035","aidName":"贾线柳","aidType":"1","organization":"镇财政分局"}]";
JSONArray jsonArray=JSONArray.fromObject(json);
for (int j= 0;j<jsonArray.size();j++){
JSONObject jsonObject=jsonArray.getJSONObject(j);
String aidName=jsonObject.getString("aidName");
String org=jsonObject.getString("organization");
if(jsonArray.size()==1){
helpPersonList.add(aidName);
}else{ 下载
helpPersonList.add(aidName+"("+povertys.get(i).getPoorName()+")");
}
oraList.add(org);
}
jsonArray遍历 取出数组中对象