1. 首页
  2. 主题
  3. Go语言

如何优雅解析http response结构体?

Dear · · 1990 次点击
成功了 是 {"resp": {"respCode": "10000","respMsg": "成功","app": {"appId": "xxxxxx"}}} 不成功是 {"resp": {"respCode": "10002","respMsg": "失败","app": ""}} 结构体怎么写,才能兼容接收response的成功和失败
然后用map来解析 app里的json? 没有更好的方案?
#2
更多评论
type AutoGenerated struct { Resp Resp `json:"resp"` } type Resp struct { RespCode string `json:"respCode"` RespMsg string `json:"respMsg"` App interface{}`json:"app"` }
#1

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中