【发布时间】:2015-08-09 14:00:17
【问题描述】:
我喜欢使用 Decode() 解组 JSON 字符串:
var message Message
decoder := 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
【问题讨论】:
标签: arrays json dictionary go