有这么一个json,我想直接转成struct struct
type whatBean struct {
action string
control string
}
...............
tmp := "{\"这个key好多\":{\"action\":\"123\",\"control\":\"456\"},\"这个key真的好多所以用map\":{\"action\":\"/roamApi/getAuthStatus.action\",\"control\":\"https://sosona.com:8443\"}}"
var grid map[string]whatBean
json.Unmarshal([]byte(tmp), &grid)
fmt.Println(grid)
结果是这样的。。是不是哪里有错误。。刚开始用,大家帮忙
map[这个key好多:{ } 这个key真的好多所以用map:{ }]
有疑问加站长微信联系(非本文作者)

等了一阵子发现没人回我,先用转成map用一下,等解决再用struct
声明的结构体统统改成大写:
别指望encoding/json库能访问到你没有导出的名字。
不要用中文Key