非标准JSON解析

时间:2022-05-27 22:33:28

http://blog.csdn.net/superit401/article/details/51734591

  1. 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}]}";
  2. JSONObject jsonObject = JSONObject.fromObject(category);
  3. JSONArray jsArray = jsonObject.getJSONArray("v-soft-list");
  4. for(int i=0;i<jsArray.size();i++){
  5. JSONObject jsObject = (JSONObject)jsArray.get(i);
  6. String typeCode = (String)jsObject.get("typecode");
  7. System.out.println(typeCode);
  8. }