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)
%!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: [{},{},{},{}]
宿州学院学报