㈠ 如何读取json字符串中的数组
json来做吧,先去下载下jar包。
下面是测试的代码:
try{
Stringstr="{'list':['1,2','3,4','5,6']}";
JSONObjectjsonObject=JSONObject.fromObject(str);//把转为对象。
Stringarray=jsonObject.getString("list");//获取list的值。
JSONArrayjsonArray=JSONArray.fromObject(array);//把list的值转为json数组对象。
Object[]strs=jsonArray.toArray();//json转为数组。
for(Objects:strs){
System.out.println(s);
}
}catch(Exceptione){e.printStackTrace();}