Go package to easily construct JSON without defined types.
- Very simple API.
- Dependency-free.
- Clean and tested code.
See docs for more details.
Go version 1.18+
go get github.com/cristalhq/jsn
j := jsn.O{
"hello": "world",
"do": jsn.A{
"go", "mod", "tidy",
},
"x": jsn.N("123456.00000000000000000000000000000000000000001"),
}
raw, _ := json.MarshalIndent(j, "", " ")
fmt.Printf("%s\n", raw)
// Output:
//{
// "do": [
// "go",
// "mod",
// "tidy"
// ],
// "hello": "world",
// "x": 123456.00000000000000000000000000000000000000001
//}
See examples: example_test.go.