json1
```json
{"time":1575018625572,"code":10006,"msg":"未查询到对应信息"}
```
json2
```json
{
"time": 1575018616175,
"code": 0,
"msg": "成功",
"data": {
"list": [
{
"id": 23638664,
"goodsId": "578575659556",
"title": "Milk Skin/奶肌牛奶素颜霜 多效保湿护肤遮瑕提亮面霜清新裸妆女",
"dtitle": "Milk Skin/奶肌牛奶素颜霜",
"originalPrice": 138,
"actualPrice": 108,
"shopType": 1,
"goldSellers": 0,
"monthSales": 3660,
"twoHoursSales": 2,
"dailySales": 12,
"commissionType": 3,
"desc": "超火素颜霜,美白遮瑕,补水保湿,提亮肤色,一瓶搞定!天然提取物,进口成分,从根部滋润美白!仙女们的懒人大福利!快速打造美丽素颜,无需卸妆烦恼",
"couponReceiveNum": 80,
"couponLink": "https://uland.taobao.com/quan/detail?sellerId=4164798236&activityId=d360a99fe2664c128db165c9c87c20c2",
"couponEndTime": "2019-12-04 23:59:59",
"couponStartTime": "2019-11-28 00:00:00",
"couponPrice": 30,
"couponConditions": "31",
"activityType": 1,
"createTime": "2019-11-28 16:38:15",
"mainPic": "https://img.alicdn.com/imgextra/i1/4164798236/O1CN01X8zWcx2Ai8UChON4v_!!4164798236.jpg",
"marketingMainPic": "https://sr.ffquan.cn/relate_pic/o_1dq8vmfdn48j1c08lpj1io51gs7u.jpg",
"sellerId": "4164798236",
"cid": 2,
"discounts": 0.78,
"commissionRate": 20.02,
"couponTotalNum": 1000,
"haitao": 0,
"activityStartTime": "",
"activityEndTime": "",
"shopName": "milkskin奶肌旗舰店",
"shopLevel": 9,
"descScore": 4.8,
"brand": 0,
"brandId": 1878088153,
"brandName": "",
"hotPush": 0,
"teamName": "风神联盟",
"itemLink": "https://detail.tmall.com/item.htm?id=578575659556",
"tchaoshi": 0,
"detailPics": "",
"dsrScore": 4.8,
"dsrPercent": 13.61,
"shipScore": 4.8,
"shipPercent": 40.83,
"serviceScore": 4.8,
"servicePercent": 40.63,
"subcid": [
111746
],
"quanMLink": 0,
"hzQuanOver": 0,
"yunfeixian": 1,
"estimateAmount": -1,
"tbcid": 50011980
}
],
"totalNum": 1,
"pageId": "1"
}
}
```
会返回上面两种类型的json,我用`map[string]interface{}`解析出来了,但是要访问里面的各个节点就难搞了,不方便使用,里面的数据的类型怎么搞呀?总是类型不对,解析个json类型都要把我搞死了。
看代码,感觉是准备写公共代码或者框架代码。外部主体结构确定,data不确定,使用json.RawMessage类型。
如果完全不确定的结构,可以使用gjson或jsoniter这类提供解析特定字段的第三方包
#11
更多评论