20
给你个例子:
这是本人的json串
{
“product”: {
“id”: 652,
“name”: “商品名字”,// 商品名称
“image”: “http://pic.qiantucdn.com/uploadfilepic/yuanwenjian/2009-07-31/58PIC_hackchong_200907317400155424fa0c68.jpg”,//商品图片地址
“code”: “11110”,//商品编码
“barCode”: “12345678900123456787”,//商品条形码
“status”: 1, //状态 1存在 0删除
“groupId”: 268, //分组ID
“standard”: “规格型号”,//规格型号
“costPrice”: 0,//成本价
“salePrice”: 22.11,//销售价
“inventory”: 0,//库存
“shopId”: 163,//店铺ID
“userId”: 170,//用户ID
“customDescription”: “”,//自定义信息
“createtime”: “2016-09-14 14:11:19”,
“updatetime”: “2016-09-14 14:11:19”
},
“statusMsg”: “OK”,
“statusDes”: “SUCCESS”,
“status”: 1,
“nowTime”: “2016-09-18 14:16:07”
}
解析:
/**
* 解析根据商品条码搜索得到的商品信息
* @param response
* @return
*/
public Map<String, Object> parseProductSearchByBar(String data) {
Map<String,Object> map = new HashMap<String, Object>();
JSONObject jsonObject;
JSONObject jsonObject1;
try {
jsonObject = new JSONObject(data);
jsonObject1 = jsonObject.getJSONObject(“product”);
map.put(“status”, jsonObject.getString(“status”));
map.put(“statusMsg”, jsonObject.getString(“statusMsg”));
map.put(“product”, jsonObject1);
} catch (JSONException e) {
e.printStackTrace();
}
return map;
}