golang控制台报错:
golang : Unmarshal: json: cannot unmarshal array into Go value of type main.MonitorServerInfo
造成原因:String类型数据传入的数据是array格式(数组套数组)
原代码:
result := make(map[string]interface{})
err := json.Unmarshal([]byte(msg), &result)
改为:
result := make([]map[string]interface{}, 0)
err := json.Unmarshal([]byte(msg), &result)

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐