json 编码 package main import ( "encoding/json" "fmt" ) type Person struct { Name string `json:"name"` Age int `json:"age"` } func main() { person := Person{"ruby", 24} b, err := json.Marshal(&person) if…
直接把结构体编码成json数据 package main import ( "encoding/json" "fmt" _ "os" ) type Address struct { Type string City string Country string } type Card struct { Name string Age int Addresses []*Address } func main() { pa := &Addres…