首页 > 其他 > 详细

golang的序列与反序列化

时间:2016-09-07 14:42:13      阅读:234      评论:0      收藏:0      [点我收藏+]

golang写backend之类的应用,还是挺方便的...
使用encoding/json包时, 必须注意, 在struct定义的属性必须是exported, 否则不会设置值. 例如:
type DRole struct { Id string `json:"id"`}
type DataRole struct { Roles []DRole `json:"roles"`}
type Role struct { TenantName string `json:"tenant_name"` TenantId string `json:"tenant_id"` Roles []string `json:"roles"`}
type Response struct { Ok bool `json:"ok"` Msg string `json:"msg"` UserName string `json:"user_name"` UserId string`json:"user_id"` Roles []Role `json:"roles"`}

golang的序列与反序列化

原文:http://www.cnblogs.com/zolo/p/5849091.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!