import "encoding/json"
type Message struct { Name string Body []string Time int64 tel string //not exported } m := Message{"jack", []string{"hello", "112"}, 1294706395881547000} r, err := json.Marshal(m) //r 是[]byte //{"Name":"jack","Body":["hello","112"],"Time":1294706395881547000} //结构中的属性自动new m1 := Message{} json.Unmarshal(r, &m1) fmt.Println(m1)//{jack [hello 112] 1294706395881547000} //结果用map[string]interface {}表示 var m2 interface{} json.Unmarshal(r, &m2) fmt.Println(m2) //map[Name:jack Body:[hello 112] Time:1.294706395881547e+18]