golang JSON
golang JSON read field from json import "github.com/tidwall/gjson" gjson.Get(jsonStr, "foo.bar.status").String() go json string 格式化 var str bytes.Buffer _ = json.Indent(&str, []byte(data), "", " ") fmt.Println("formated: ", str.String()) time.Time 序列化 https://www.cnblogs.com/chenqionghe/p/13409556.html json.Marshal(struct { *User Password bool `json:"password,omitempty"` }{ User: user, }) json.Marshal() // 序列化 + 格式化 resp2, _ := json.MarshalIndent(s, "", " ") json.Unmarshal() struct json tag https://colobu.com/2017/06/21/json-tricks-in-Go/ type Result struct { Count int `json:"count"` Data MyStruct `json:"data,omitempty"` } func main() { out := shellExec(shell) var result Result json.Unmarshal([]byte(out), &result) fmt.Println(result.Count) } gjson https://github.com/tidwall/gjson ...