
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.
Tag
17 articles

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.

Compare URL, header, media type and date-based API versioning in Go, with one handler serving two views, a frozen v1 test and Sunset headers.

Validate Go API requests with a small collector: JSON Pointer paths, nested fields, cross-field rules, rune-aware lengths and 340 ns for a valid order.

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.