go json.Unmarshal不工作
我有json,它没有被解码成struct 我知道代码中的某个地方有错误,但我被卡住了,不知道错误在哪里,我做错了什么 请帮帮我,这是我的密码:go json.Unmarshal不工作,json,go,unmarshalling,Json,Go,Unmarshalling,我有json,它没有被解码成struct 我知道代码中的某个地方有错误,但我被卡住了,不知道错误在哪里,我做错了什么 请帮帮我,这是我的密码: type GOOGLE_JSON struct { code string `json:"code"` clientId string `json:"clientId"` redirectUri string `json:"redirectUri"` } body := []byte(`{"code":"11
type GOOGLE_JSON struct {
code string `json:"code"`
clientId string `json:"clientId"`
redirectUri string `json:"redirectUri"`
}
body := []byte(`{"code":"111","clientId":"222","redirectUri":"333"}`)
//google_json := GOOGLE_JSON{}
var google_json GOOGLE_JSON
err := json.Unmarshal(body, &google_json)
if err != nil {
fmt.Println(err)
}
fmt.Println(google_json)
我发现了错误
是
必须是大写字母
type GOOGLE_JSON struct {
Code string `json:"code"`
ClientId string `json:"clientId"`
RedirectUri string `json:"redirectUri"`
}
我没有注意
Code // <- exported
ClientId // <- exported
RedirectUri // <- exported
code // <-- not exported
clientId // <-- not exported
redirectUri // <-- not exported
code//我一发表帖子,stackoverflow就突出显示了go代码,它立即让我想到了导出值和未导出值
Code // <- exported
ClientId // <- exported
RedirectUri // <- exported
code // <-- not exported
clientId // <-- not exported
redirectUri // <-- not exported