请问类似这样的json如何解析了
var json_list_str = `[{"a":1,"b":2},{"a":1,"b":2},{"a":1,"b":2}]`
<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