内容不固定的json如何解析呀?新手,搜索了集中方法,还是不知道如何搞

123445 · · 1873 次点击 · 开始浏览    置顶
这是一个创建于 的主题,其中的信息可能已经有所发展或是发生改变。

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类型都要把我搞死了。

有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1873 次点击  
加入收藏 微博
11 回复  |  直到 2019-12-24 19:33:22
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传