首页 > 代码库 > jsonArray遍历 取出数组中对象

jsonArray遍历 取出数组中对象

字符串转JSONArray  然后遍历array 
下载 

Java代码  技术分享

  1. List<String> helpPersonList=new ArrayList<>();  

  2.                List<String> oraList=new ArrayList<>();  

  3.   

  4.                String json="[{"aid":"aid-0035","aidName":"贾线柳","aidType":"1","organization":"镇财政分局"}]";  

  5.                JSONArray jsonArray=JSONArray.fromObject(json);  

  6.                for (int j= 0;j<jsonArray.size();j++){  

  7.                     JSONObject jsonObject=jsonArray.getJSONObject(j);  

  8.                    String aidName=jsonObject.getString("aidName");  

  9.                    String org=jsonObject.getString("organization");  

  10.                    if(jsonArray.size()==1){  

  11.                        helpPersonList.add(aidName);  

  12.                    }else{  下载 

  13.                        helpPersonList.add(aidName+"("+povertys.get(i).getPoorName()+")");  

  14.                    }  

  15.                    oraList.add(org);  

  16.                }  


jsonArray遍历 取出数组中对象