json.Unmarshal

https://api.weixin.qq.com/sns/oauth2/access_token?appid=




// OK
type AccessTokenRespTODO struct {
Access_token string
ExpiresIn int32
RefreshToken string
Openid string
Scope string
Unionid string
}
// NOT OK
type AccessTokenRespTODO struct {
access_token string
}
// NOT OK
type AccessTokenRespTODO struct {
AccessToken string
}


t := AccessTokenRespTODO{}

// {access_token:44_hNaGeAc,expires_in:7200,refresh_token:44_XuLkebtyS5DclSqQG7WF1f--rOm8DA_RgmqKRmXC-6aQ3Sci_T6OWBI,openid:olLC-TSaA,scope:snsapi_login,unionid:oF88mRP8}

err = json.Unmarshal([]byte(resp), &t)

posted @ 2021-05-08 15:48  papering  阅读(122)  评论(0编辑  收藏  举报