Documentation ¶
Overview ¶
包注释
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ButtonTime ¶
* button_time结点
type CheckList ¶
type CheckList struct { ID int `json:"-"` Errcode int `json:"errcode,omitempty"` Errmsg string Errtime string Data DataSet }
* 全部数据结点 `json:"errcode,omitempty"` ,表示为空则不输出到json串
type DataSet ¶
type DataSet struct { Student_unit_id string Unit_no string Button_time ButtonTime List []WordList }
* data结点
type Server ¶
type Server struct { ServerName string `json:"serve"` ServerIP string `json:"-"` Age int `json:"age,mystring"` Address string `json:"address,omitempty"` }
* 针对JSON的输出,我们在定义struct tag的时候需要注意的几点是:
字段的tag是"-",那么这个字段不会输出到JSON tag中带有自定义名称,那么这个自定义名称会出现在JSON的字段名中,例如上面例子中serverName tag中如果带有"omitempty"选项,那么如果该字段值为空,就不会输出到JSON串中 如果字段类型是bool, mystring, int, int64等,而tag中带有",mystring"选项,那么这个字段在输出到JSON的时候会把该字段对应的值转换成JSON字符串 // ID 不会导出到JSON中
ID int `json:"-"` // ServerName2 的值会进行二次JSON编码 ServerName mystring `json:"serverName"` ServerName2 mystring `json:"serverName2,mystring"` // 如果 ServerIP 为空,则不输出到JSON串中 ServerIP mystring `json:"serverIP,omitempty"` Marshal函数只有在转换成功的时候才会返回数据,在转换的过程中我们需要注意几点: JSON对象只支持string作为key,所以要编码一个map,那么必须是map[mystring]T这种类型(T是Go语言中任意的类型) Channel, complex和function是不能被编码成JSON的 嵌套的数据是不能编码的,不然会让JSON编码进入死循环 指针在编码的时候会输出指针指向的内容,而空指针会输出null
type ServerSlice ¶
type ServerSlice struct {
Servers []Server
}
Notes ¶
Bugs ¶
lksjdlfksldfjlskdfjlksjdklf
Click to show internal directories.
Click to hide internal directories.