
APIs
JSON Marshaling in Go With Tags Omitempty and Custom Types
A tour of encoding/json in Go: struct tags, omitempty and omitzero, nil versus empty, time and bytes, int64 precision, HTML escaping and measured speed.
14 min read
Everything you need to level up your coding skills.

A tour of encoding/json in Go: struct tags, omitempty and omitzero, nil versus empty, time and bytes, int64 precision, HTML escaping and measured speed.

What Go's experimental encoding/json/v2 changes: case-sensitive keys, rejected duplicates, empty arrays for nil slices, Duration formats. v1 unchanged.

Tell absent, null and zero apart when decoding JSON in Go: why pointers fail, what RawMessage and a generic Optional give you, and omitzero on output.
We send one email when a new article is published. No spam.