json复杂json解析

jackylee92 · · 4731 次点击
<pre><code>json_list_str := [{"a":1,"b":2},{"a":1,"b":2},{"a":1,"b":2}] type Whatever struct { A int `json:"a"` B int `json:"b"` } var result []*Whatever err := json.Unmarshal([]byte(json_list_str), &result) if err != nil { // handle with error here } </code></pre> encoding/json包提供了支持, 需要给变量增加类似`json:"a"`的tag,支持类型嵌套
#1