我喜欢使用 Decode() 解组 JSON 字符串:var message Messagedecoder := json.NewDecoder(s)err = decoder.Decode(&message)我的数据结构是type Message map[string]interface{}测试数据如下:{ "names": [ "HINDERNIS", "TROCKNET", "UMGEBENDEN" ], "id":1189, "command":"checkNames"}它适用于数字和字符串,但对于字符串数组,我得到以下恐慌:panic: interface conversion: interface is []interface {}, not []string
1 回答
- 1 回答
- 0 关注
- 162 浏览
添加回答
举报
0/150
提交
取消