Golang和JSON与结构体数组

Golang和JSON与结构数组
I would like to create a JSON of a GatewayInfo where the type are defined like this:
type SpanInfo struct {
imsi string
network string
network_status string
signal_quality int
slot int
state string
}
type GatewayInfo []SpanInfo
The gateway information is created with:电虾机电路图>热电偶校验装置
var gatewayInfo = make(GatewayInfo, nb_spans)
To create the JSON, I use the json.Marshal function:
gatewayInfo := getGatewayInfo(spans)
污泥脱水剂log.Printf("Polling content: %s
", gatewayInfo)
jsonInfo, _ := json.Marshal(gatewayInfo)
log.Printf("jsonInfo: %s
", jsonInfo)
米勒板
Unfortunately the result is not what I was expecting:
人工天竺黄2015/02/09 13:48:26 Polling content: [{652020105829193 20801 Registered (Roaming) %!s(int=17)
tjstart
%!s(int=2) } {652020105829194 20801 Registered (Roaming) %!s(int=16) %!s(i nt=3) } {652020105829192 20801 Registered (Roaming) %!s(int=19) %!s(int=1) } {652020105829197 20801 Registered (Roaming) %!s(int=19) %!s(int=4) }]
2015/02/09 13:48:26 jsonInfo: [{},{},{},{}]

本文发布于:2024-09-20 15:19:55,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/156735.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:电路图   热电偶   结构   脱水剂   数组   污泥   装置   校验
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议