golang JSON read field from json 1 2 import "github.com/tidwall/gjson" gjson.Get(jsonStr, "foo.bar.status").String() go json string 格式化 1 2 3 var str bytes.Buffer _ = json.Indent(&str, []byte(data), "", " ") fmt.Println("formated: ", str.String()) time.Time 序列化 https://www.cnblogs.com/chenqionghe/p/13409556.html 1 2 3 4 5 6 json.Marshal(struct { *User Password bool `json:"password,omitempty"` }{ User: user, }) 1 2 3 4 json.Marshal() // 序列化 + 格式化 resp2, _