我有未解碼為結構的 json。我知道我的代碼中的某個地方有這個錯誤,但我被卡住了,不知道錯誤在哪里,我做錯了什么請幫助我,這是我的代碼: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_JSONerr := json.Unmarshal(body, &google_json)if err != nil { fmt.Println(err)}fmt.Println(google_json)
1 回答

慕運維8079593
TA貢獻1876條經驗 獲得超5個贊
我發現錯誤
曾是
type GOOGLE_JSON struct {
code string `json:"code"`
clientId string `json:"clientId"`
redirectUri string `json:"redirectUri"`
}
必須是大寫字母
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
- 1 回答
- 0 關注
- 178 瀏覽
添加回答
舉報
0/150
提交
取消