This is a creation in Article, where the information may have evolved or changed.
Photo from: http://qiita.com/hogedigo/items/f914992baf7a2ed12b9c
National Day seven days, you eat more, or sleep more? Holiday seven days is fleeting, the next seven days you may feel very diffuse.
Anyway Golang has a library of JSON (Encoding/json) processing, and a third-party Simplejson(Https://github.com/bitly/go-simplejson). But it's always easier to feel like a dynamic language like Python, in Python, arrays and dictionaries are easy to handle, and JSON is easy to transfer.
The biggest problem with Encoding/json is that it is not flexible enough to pre-define a lot of structs to encode and decode, which is very inconvenient for processing JSON files with variable structure.
Here is a library called Go-dproxy(Https://github.com/koron/go-dproxy), which is very convenient and simple, does not require a pre-defined struct, and can be looked up like XPath.
Here is an example:
or download this file from gist(https://gist.github.com/liubin/5521035cb9dab26e5981549b2cea355a) to perform:
$ go Get github.com/koron/go-dproxy
$ go Build dproxy-test.go
$./dproxy-test
Can.
In short, this library processing JSON should be very simple, I hope to help you.
Click to read the original version can see the PC Edition.
Have good things to share
View Original: http://www.zoues.com/2016/10/20/golang%e4%b8%ad%e4%b8%80%e4%b8%aa%e4%b8%8d%e9%94%99%e7%9a%84%e5%a4%84%e7% 90%86-json-%e7%9a%84%e5%ba%93-go-dproxy/