非标准JSON解析

时间:2023-02-20 19:08:31
String category = "{'v-soft-list':[{typecode:'zhuanbi',gametype:'赚币',count:5},{typecode:'dongzuo',gametype:'动作',count:12},{typecode:'maoxian',gametype:'冒险',count:14},{typecode:'xiuxian',gametype:'休闲',count:61},{typecode:'zhili',gametype:'智力',count:17},{typecode:'gaoxiao',gametype:'搞笑',count:6},{typecode:'celue',gametype:'策略',count:4},{typecode:'qipai',gametype:'棋牌',count:2}]}";

JSONObject jsonObject = JSONObject.fromObject(category);
JSONArray jsArray = jsonObject.getJSONArray("v-soft-list");
for(int i=0;i<jsArray.size();i++){
JSONObject jsObject = (JSONObject)jsArray.get(i);
String typeCode = (String)jsObject.get("typecode");
System.out.println(typeCode);
}