为了账号安全,请及时绑定邮箱和手机立即绑定

Go map[int]struct JSON Marshal

Go map[int]struct JSON Marshal

Go
陪伴而非守候 2021-07-28 17:48:49
尝试在 go 中将 map[int] 解析为用户定义的结构:这是数据模式。type Recommendation struct {    Book  int     `json:"book"`    Score float64 `json:"score"`}这是 json 编组:ureco := make(map[int]data.Recommendation)ureco, _ = reco.UserRunner()json, _ := json.Marshal(ureco)fmt.Println(json)其中 reco.UserRunner() 返回适当的结构类型。这将打印一个空的 json 对象:[]更新:错误信息:json: unsupported type: map[int]data.Recommendation那么我如何 json 结构映射?还是有替代方法?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 221 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号