GO 处理 json ,棘手

benson · · 2525 次点击
非常感谢,膜拜
#2
更多评论
```golang package main import ( "fmt" "encoding/json" ) const result = `{"name":"zhangsan","data":{"result0":100,"result1":200,"result2":300,"result3":400,"result5":100}}` type Result struct { Data map[string]int32 `json:"data"` } func main() { var r Result if err := json.Unmarshal([]byte(result), &r); err != nil { panic(err) } statics := make(map[int32]int32) for _, value := range r.Data { statics[value] = statics[value] + 1 } fmt.Println(statics) } ```
#1
处理已知的结构没什么问题
#3