我无法解析具有字符串键和数组作为值的 json,最终出现json: Unmarshal(non-pointer map[string]interface {})错误。package mainimport ( "encoding/json" "fmt")func main() { var s map[string]interface{} err := json.Unmarshal([]byte("{\"a\":[1,2,3]}"), s) if err != nil { panic(err) } fmt.Println("Nice parse!")}https://go.dev/play/p/AXlF8I-f9-p
1 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
Unmarshal 解析 JSON 编码的数据并将结果存储在 v 指向的值中。如果 v 为 nil 或不是指针,则 Unmarshal 返回 InvalidUnmarshalError。添加 &s 作为参数
err := json.Unmarshal([]byte("{\"a\":[1,2,3]}"), &s)- 1 回答
- 0 关注
- 215 浏览
添加回答
举报
0/150
提交
取消
