java解析json字符串 放到数组中
{"category_list":["美食,江浙菜,上海菜","美食,江浙菜,淮扬菜","美食,江浙菜,浙江菜","美食,江浙菜,南京菜","美食,江浙菜,苏帮菜","美...
{"category_list":["美食,江浙菜,上海菜","美食,江浙菜,淮扬菜","美食,江浙菜,浙江菜","美食,江浙菜,南京菜","美
食,江浙菜,苏帮菜","美食,江浙菜,杭帮菜","美食,江浙菜,宁波菜","美食,江浙菜,无锡菜","美食,江浙菜,舟山菜""美食,日韩菜,韩国菜","美食,日韩菜,其它日韩菜","美食,火锅","美
食,清真菜","美食,小吃快餐","美食,海鲜","美食,烧烤","美食,自助餐","美食,面包甜点","美食,茶餐厅","美食,咖啡厅","美
食,其它美食,北京家常菜","美食,其它美食,官府菜","美食,其它美食,云贵菜","美食,其它美食,湖北菜","美食,其它美食,山西菜","美
食,其它美食,豫菜","美食,其它美食,天津菜","美食,其它美食,新疆菜","美食,其它美食,农家菜","美食,其它美食,创意菜","美食,其
它美食,素菜","美食,其它美食,烤鸭","美食,其它美食,江西菜","美食,其它美食,蒙古菜","美食,其它美食,广西菜","美食,其它美食,
冀菜","美食,其它美食,陕西菜","美食,其它美食,青海菜","美食,其它美食,西藏菜","美食,其它美食,酒楼","美食,其它美食,家常
菜","美食,其它美食,私家菜","美食,其它美食,民族菜","美食,其它美食,冷饮店","美食,其它美食,其它中餐厅","基础设施,交通设施,
交通服务相关","基础设施,交通设施,公交车站","基础设施,交通设施,地铁站","基础设施,交通设施,港口码头","基础设施,交通设施,火车
站","基础设施,交通设施,轻轨站","基础设施,交通设施,过境口岸","基础设施,交通设施,长途汽车站","基础设施,交通设施,飞机场","基
础设施,交通设施,公交线路","基础设施,交通设施,地铁线路","基础设施,交通设施,其它交通设施","基础设施,公共设施,公共厕所","基础设
施,公共设施,公用电话","基础设施,公共设施,紧急避难场所","基础设施,公共设施,其它公共设施","基础设施,道路附属,收费站","基础设
施,道路附属,服务区","基础设施,道路附属,其它道路附属","基础设施,其它基础设施","医疗保健,专科医院,齿科","医疗保健,专科医院,整
形","医疗保健,专科医院,眼科","医疗保健,专科医院,耳鼻喉","医疗保健,专科医院,胸科","医疗保健,专科医院,骨科","医疗保健,专科
医院,肿瘤","医疗保健,专科医院,脑科","医疗保健,专科医院,妇产科","医疗保健,专科医院,儿科","医疗保健,专科医院,传染病医院","
医疗保健,专科医院,精神病医院","医疗保健,专科医院,其它专科医院","医疗保健,综合医院","医疗保健,诊所","医疗保健,急救中心","医
疗保健,药房药店","医疗保健,疾病预防"]} 展开
食,江浙菜,苏帮菜","美食,江浙菜,杭帮菜","美食,江浙菜,宁波菜","美食,江浙菜,无锡菜","美食,江浙菜,舟山菜""美食,日韩菜,韩国菜","美食,日韩菜,其它日韩菜","美食,火锅","美
食,清真菜","美食,小吃快餐","美食,海鲜","美食,烧烤","美食,自助餐","美食,面包甜点","美食,茶餐厅","美食,咖啡厅","美
食,其它美食,北京家常菜","美食,其它美食,官府菜","美食,其它美食,云贵菜","美食,其它美食,湖北菜","美食,其它美食,山西菜","美
食,其它美食,豫菜","美食,其它美食,天津菜","美食,其它美食,新疆菜","美食,其它美食,农家菜","美食,其它美食,创意菜","美食,其
它美食,素菜","美食,其它美食,烤鸭","美食,其它美食,江西菜","美食,其它美食,蒙古菜","美食,其它美食,广西菜","美食,其它美食,
冀菜","美食,其它美食,陕西菜","美食,其它美食,青海菜","美食,其它美食,西藏菜","美食,其它美食,酒楼","美食,其它美食,家常
菜","美食,其它美食,私家菜","美食,其它美食,民族菜","美食,其它美食,冷饮店","美食,其它美食,其它中餐厅","基础设施,交通设施,
交通服务相关","基础设施,交通设施,公交车站","基础设施,交通设施,地铁站","基础设施,交通设施,港口码头","基础设施,交通设施,火车
站","基础设施,交通设施,轻轨站","基础设施,交通设施,过境口岸","基础设施,交通设施,长途汽车站","基础设施,交通设施,飞机场","基
础设施,交通设施,公交线路","基础设施,交通设施,地铁线路","基础设施,交通设施,其它交通设施","基础设施,公共设施,公共厕所","基础设
施,公共设施,公用电话","基础设施,公共设施,紧急避难场所","基础设施,公共设施,其它公共设施","基础设施,道路附属,收费站","基础设
施,道路附属,服务区","基础设施,道路附属,其它道路附属","基础设施,其它基础设施","医疗保健,专科医院,齿科","医疗保健,专科医院,整
形","医疗保健,专科医院,眼科","医疗保健,专科医院,耳鼻喉","医疗保健,专科医院,胸科","医疗保健,专科医院,骨科","医疗保健,专科
医院,肿瘤","医疗保健,专科医院,脑科","医疗保健,专科医院,妇产科","医疗保健,专科医院,儿科","医疗保健,专科医院,传染病医院","
医疗保健,专科医院,精神病医院","医疗保健,专科医院,其它专科医院","医疗保健,综合医院","医疗保健,诊所","医疗保健,急救中心","医
疗保健,药房药店","医疗保健,疾病预防"]} 展开
展开全部
java解析json字符串时将大括号中的对应为一个类,里面的数据对应为类的属性,最后用数组接受即可。
示例关键代码如下:
//导入 net.sf.json.JSONArray和net.sf.json.JSONObject 两个jar 包
String str = "[{name:'a',value:'aa'},{name:'b',value:'bb'},{name:'c',value:'cc'},{name:'d',value:'dd'}]" ; // 一个未转化的字符串
JSONArray json = JSONArray.fromObject(str ); // 首先把字符串转成 JSONArray 对象
if(json.size()>0){
for(int i=0;i<json.size();i++){
JSONObject job = json.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
System.out.println(job.get("name")+"=") ; // 得到 每个对象中的属性值
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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();}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
阿里有专门的工具叫fastJson,主要是对json做处理的。
可以将json字符串转换成对应的对象集合,希望能给你帮助吧
可以将json字符串转换成对应的对象集合,希望能给你帮助吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jsonArray
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-11-09
展开全部
可以用阿里巴巴的开源json库,fastjson来转,很简单
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询