需要解析json格式如下:
![](http://upload-images.jianshu.io/upload_images/6918193-abe39cad4870a05a.png?imageMogr2/auto-orient/strip)
说一说三种解析方式,1.利用结构体struct解析;2.利用interface空接口解析;3.第三方解析库;
1.strcut解析方式:
定义strcut结构体,利用json.Unmarshal解析,存放到strcut;
参考:https://segmentfault.com/q/1010000000583211
![](http://upload-images.jianshu.io/upload_images/6918193-0664d9bf18bd23a9.png?imageMogr2/auto-orient/strip)
![](http://upload-images.jianshu.io/upload_images/6918193-15e227b20f191ad4.png?imageMogr2/auto-orient/strip)
2. 利用interface解析:
参考:https://www.golangtc.com/t/569e026ab09ecc08310000b0
![](http://upload-images.jianshu.io/upload_images/6918193-596e1d6d5dd49859.png?imageMogr2/auto-orient/strip)
3.第三方解析库
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)