1、结构体转Json
jsons, errs := json.Marshal(cert)
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println(string(jsons))
2、Json转结构体 ··· cert1 := new(lbv1alpha1.Cert) json.Unmarshal([]byte(jsons), &cert1)//json解析到结构体里面 fmt.Println(cert1) ···
需要引用的包:
···
encoding/json
···
个人微信公众号:
作者:jiankunking 出处:http://blog.csdn.net/jiankunking