Documentation ¶
Overview ¶
Package json has some utilities for JSON codec
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToStruct ¶
JSONToStruct convert JSON to a Struct The struct must have json tags
:param interFace: A pointer to a variable of the struct data with json tags :param jsonData: The JSON data
Example
type NTP struct { NTPServersData struct { SourceInterface string `yaml:"source_interface" json:"source_interface" xml:"source_interface"` NTPServerKey []struct { IPv4Host string `yaml:"ipv4_host" json:"ipv4_host" xml:"ipv4_host"` Priority bool `yaml:"priority" json:"priority" xml:"priority"` } `yaml:"ntp_servers" json:"ntp_servers" xml:"ntp_servers"` } `yaml:"ntp" json:"ntp" xml:"ntp"` } var a NTP err := json.JSONToStruct(&a, ntpJson) if err != nil { log.Fatal(err) } fmt.Println(a)
func StructToJSON ¶
StructToJSON convert struct to JSON The struct must have json tags
:param interFace: The struct data with json tags
Example
var a NTP thing, err := xml.StructToJSON(a) fmt.Println(thing)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.