我喜歡使用 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 回答
- 0 關注
- 174 瀏覽
添加回答
舉報
0/150
提交
取消