java json array resolved

Copyright: without her consent, and not to reprint the article, if reproduced please note the link address! https://blog.csdn.net/qq_38366657/article/details/87620574

1.java json array resolved

​​​​​​​String array="[{'name':'李*冰','age':'12'},{'name':'李*冰','age':'12'}]";
//解析json数组
JSONArray json = JSONArray.parseArray(array);//先将对象转成json数组
for(int i= 0;i< json.size();i++){
    JSONObject job = json.getJSONObject(i);//获取json数据 里面的1行json
    String usersid = job.getString("name");//getString这样是直接得到string型
    String obje = job.getString("age");
    System.out.println(usersid);//输出
    System.out.println(obje);//输出
}

 

Guess you like

Origin blog.csdn.net/qq_38366657/article/details/87620574