java怎样截取JSONArray数组中的json字符串

如题所述

json来做吧,先去下载下jar包。下面是测试的代码:

try{
String str = "{'list':['1,2','3,4','5,6']}";
JSONObject jsonObject = JSONObject.fromObject(str); //吧转为json对象
String array= jsonObject.getString("list"); //获取list的值
JSONArray jsonArray = JSONArray.fromObject(array); //吧list的值转为json数组对象
Object[] strs = jsonArray.toArray(); //json转为数组
for(Object s:strs){
System.out.println(s);
}
}catch(Exception e){e.printStackTrace();}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-10-12
这得看具体的字符串了

~