我嘗試創建JSON數組Golang創建JSON數組
type Data struct {
Veggies Vegetables
array array } type array map[string] []int
func main(){
vegetables := Vegetables{}
vegetables["Carrots"] = 21
n:= array{}
n ["array"]= [] int {1, 1 ,1}
d := Data{ vegetables,n}
json.MarshalIndent(d, "", " ")}
請解釋爲什麼看不到陣列?
輸出:{ 「素食者」:{ 「胡蘿蔔」:21 } } –