Use tj
to produce well-formed schemaless JSON:
json.Marshal(tj.O{
"hello": tj.A{
"world",
42,
tj.O{
"go": nil,
},
},
})
tj/json2go
tool produces tj
trees from existing JSON files.
This package comes in handy for interacting with large amounts of external systems all demanding different JSON schemas. Creating structures, tagging them and filling them is overkill if the structures are used just once.
tj.O
and tj.A
are short and unobtrusive, this makes the resulting code
readable.
If you find yourself using tj
to describe JSONs with the same schema more than
once then it's time to switch to Go struct-backed JSON generation.
Copyright Tectonic Labs Ltd.
Licensed under Apache 2.0 license.
Authors: