我正在開始從 Python 遷移到 GoLang,并且我正在嘗試了解數(shù)據(jù)類型。我需要將地圖編組到以下 JSON,但我不太確定我的地圖應該如何構(gòu)建。這是我嘗試過的,但對我不起作用。data := map[string]string{"Offset": "0", "Properties": map[string]string{"key": "Type", "value": "User"}, "Category": "all", "Locations": map[string]string{}, "Accounts": "100" }data_json, _ := json.Marshal(data)fmt.Println(string(data_json))預期結(jié)果:{"Locations": [],"Dates": [],"Properties": [ { "key": "Type", "value": "User" } ], "Category": "all", "Accounts": [], "Offset": 0, "Limit": 100}
- 1 回答
- 0 關(guān)注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消