Go pattern: loose
I once found a neat (in my opinion) way to make it easier to write (and arguably still read easily) one-off JSON payloads. Part of the trick is to introduce a small local helper type (for which I hadn’t found a better name yet):
type loose map[string]any json.NewEncoder(os.Stdout).Encode(loose{ "foo": "go1.18+", "fee": loose{ "fum": "baz", }, })
Update (2023): Replaced interface{}
with any
, available since Go ~1.18.