亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

去 json.Unmarshal 不工作

去 json.Unmarshal 不工作

Go
精慕HU 2021-09-27 10:02:57
我有未解碼為結構的 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


查看完整回答
反對 回復 2021-09-27
  • 1 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號