Documentation ¶
Overview ¶
Decoding arbitrary nested maps from JSON using generic interface{}s.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding basic static types.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Decode from a stream, using io.Reader and json.Decoder.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Delayed parsing/unmarshaling with json.RawMessage
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encode into a stream, using io.Writer and json.Encoder.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Generic decoding demonstrating int/float and UseNumber.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Basic generic encoding/decoding with interface{}.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding maps.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Marshaling a deeply nested map.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Optional struct fields via pointer decoding.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding pointers.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding slices.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Custom encoding/marshaling of a struct/type.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Ommitting a struct field when encoding it.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Unmarhalling with an embedded struct.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Fieldtags in structs to map to JSON object key names.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding structs, omitting empty fields.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding structs without default-valued fields.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Combines delayed with generic parsing to parse the proper struct type.
Shows how to parse structs that can be distinguished by a field value to dispatch to the proper type.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Encoding/decoding structs.
Eli Bendersky [https://eli.thegreenplace.net] This code is in the public domain.
Source Files ¶
- arbitrary-generic-map.go
- basictypes.go
- decode-stream.go
- delay-parse-rawmessage.go
- encode-writer.go
- generic-int-float-decode.go
- generic.go
- maps.go
- marshal-map-of-map-of-interface.go
- pointer-struct-optional.go
- pointers.go
- slices.go
- struct-custom-marshal.go
- struct-omit-field.go
- structs-embedded.go
- structs-fieldtags.go
- structs-omitempty.go
- structs-partial.go
- structs-unmarhsal-as-interface.go
- structs.go