This is a creation in Article, where the information may have evolved or changed.
When parsing json, I used a fairly good framework, bitly company Open source a simplejson package called, in the processing of the unknown structure of the JSON is very convenient, detailed examples are as follows:
PackageMainImport("Go-simplejson-master"//import Package"FMT")funcMain() {JS, ERR: = Simplejson.Newjson([]byte(`{"Test": {"Array": [1, "2", 3],"int": Ten,"float": 5.150,"Bignum": 9223372036854775807,"string": "Simplejson","bool": True }}`))ifErr! =Nil{ }Else{arr, _: = js.Get("Test").Get("Array").Array() I, _: = js.Get("Test").Get("int").Int() MS: = JS.Get("Test").Get("string").muststring() F: = js.Get("Test").Get("Float").MustFloat64() fmt.Println(arr,I,Ms,f)}}The download address for this framework is: Https://github.com/bitly/go-simplejson