处理json格式数据。。
String s0 = "{cart_1325036696007:{goods_id:"100015",goods_name:"澳大利亚进口绵羊",goods_imgsrc:"http://192.168.1.180:7001//gwadmin/uploadimg/spxc/2011/12/9/100016_00948703_68.jpg",specs:"b555bfj05d7dcg307h91323398584156",specsstr:"颜色:黑色 尺寸:L",price:4765,stock:15,count:6},cart_1325036702105:{goods_id:"100015",goods_name:"澳大利亚进口绵羊",goods_imgsrc:"http://192.168.1.180:7001//gwadmin/uploadimg/spxc/2011/12/9/100016_00948703_68.jpg",specs:"787a9f5he93chcifh951323398314484",specsstr:"颜色:黑色 尺寸:XL",price:4700.15,stock:12,count:1},cart_1325136643984:{goods_id:"100015",goods_name:"澳大利亚进口绵羊",goods_imgsrc:"http://192.168.1.180:7001//gwadmin/uploadimg/spxc/2011/12/9/100015_00399656_68.jpg",specs:"8466347bi6eia43hd6j1323398639859",specsstr:"颜色:灰色 尺寸:XL",price:4600,stock:3,count:1}};";
String s= java.net.URLDecoder.decode(s0, "utf-8");
System.out.println(s);
JSONObject o = new JSONObject(s);
System.out.println(o.get("cart_1325036696007")); //根据属性,获取值
System.out.println(o.toString()); //得到字符串
System.out.println(o.names().get(2)); //获取对象中第三组属性名
System.out.println(o.names().length()); //获取对象中属性个数
//System.out.println(o.names().getJSONArray(1)); //获取对象中属性个数
//names(jsonObjectName) 私有方法 获取该对象的所有属性名,返回成JSONArray。
//JSONObject.getNames(jsonObjectName) 静态方法 获取对象的所有属性名,返回成数组。
System.out.println(JSONObject.getNames(o.getJSONObject("cart_1325036696007"))[1]);
System.out.println(o.getJSONObject("cart_1325036696007").names().get(1));
System.out.println(o.length()); //共有几组对象
System.out.println(o.has("cart_1325036696007")); //有无该该值