JSON in Go: Difference between revisions
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
<syntaxhighlight lang='go'> | <syntaxhighlight lang='go'> | ||
type Item struct { | type Item struct { | ||
Color string | |||
Size int | |||
Options []string | |||
} | } | ||
Revision as of 17:10, 25 August 2023
Internal
Overview
JSON Marshalling Go → JSON
JSON marshalling means generating a JSON representation from a Go object. It is done with json.Marshal()
. The result is a byte array. To convert the byte array to a string, see:
Map Marshalling
Struct Marshalling
By default, only fields that start with capital letters are marshaled. The fields that start with lower caps are invisible to the marshaling process.
type Item struct {
Color string
Size int
Options []string
}
TO PROCESS: https://golang.cafe/blog/golang-json-marshal-example.html