标准的就简单通用。
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)) }
时间: 2024-11-08 23:53:25