~~~
这种JSON数组生成有简便的方法?
生成JSON数组, 因为我要按顺序来的, 默认GO MAP是随机打乱的
有更方便的代码写法解决?
addjson := ""
mapJson := make(map[string]string)
mapJson["name"] = "按钮1"
mapJson["number"] = "1"
json1, _ := json.Marshal(mapJson)
addjson += string(json1)
mapJson["name"] = "按钮2"
mapJson["number"] = "2"
json1, _ = json.Marshal(mapJson)
addjson += "," + string(json1)
mapJson["name"] = "按钮3"
mapJson["number"] = "3"
json1, _ = json.Marshal(mapJson)
addjson += "," + string(json1)
fmt.Println("[" + addjson + "]")
~~~
有疑问加站长微信联系(非本文作者)