-2
我想解析提及的json。解析嵌套json對象golang
{ 「foo」 的: [{ 「欄」:1, 「巴茲」:2},{ 「酒吧」:4 「巴茲」:25}], 「更多」: 「文本」 }
使用以下結構來解組
type FooStruct struct {
Bar int `json:"bar"`
Baz int `json:"baz"`
}
type ResponseStruct struct {
More string `json:"more"`
Foo []FooStruct `json:"foo"`
}
var contentHtml ResponseStruct
err = json.Unmarshal(<byte_array>, &contentHtml)
fmt.Printf("%+v", contentHtml.FooStruct[0].Bar)
問題是什麼? https://play.golang.org/p/-B3jNUqQHF – RoninDev