map接收json unmarshal出来的数据时注意
2017-10-19 本文已影响0人
krystollia
data := map[string]interface{}{}
jsonStrs := []string{
`{"k1":"v1","k2":"v2"}`,
`{"k3":"v3","k2":2}`,
`{"k4":"v4","k5":"v5"}`,
}
for _, s := range jsonStrs {
json.Unmarshal([]byte(s), &data)
}
for循环结束后data中会包含k1,k2,k3,k4,k5五个元素