标准的就简单通用。
package main import ( "encoding/json" "fmt" "log" ) func main() { c := make(map[string] interface{}) c["name"] = "Gopher" c["title"] = "programmer" c["contack"] = map[string] interface{} { "home": "412323", "cell": "5223.222.22", } data, err := json.MarshalIndent(c, "", " ") if err != nil { log.Println("ERROR:", err) return } fmt.Println(string(data)) }