/jj

Read arbitrary and deeply nested JSON structures in Go with as little boilerplate code as possible.

Primary LanguageGo

jj

Read arbitrary and deeply nested JSON structures in Go with as little boilerplate code as possible.

Build Status GoDoc

var data jj.Value
str := `{ "foo": "bar", "bar": { "sub": "val", "int": 4 }, "baz": ["a", 9] }`
err := json.Unmarshal([]byte(str), &data)

fmt.Println(data.At("bar", "sub").String()) // panics if the key does not exist
// => "val"

fmt.Println(data.At("x").StringOrDefault("default")) // always succeeds
// => "default"

fmt.Println(data.At("baz", 1).Number())
// => 9