A simple JSON-Object generator
- Support dot-method, just like access the member variables
- Support using index to get the element of array
go get github.com/collatzc/jsonl
Using JSONObj
to generate a JSON-Object:
reader := bytes.NewReader([]byte(`
{
"root" : {
"key" : "abc"
}
}
`))
j, err := JSONObj(reader)
# get the value of "key"
key := j.Get("root.key")
Work well with array:
reader := bytes.NewReader([]byte(`
{
"root": [
{
"key": "abc"
},
{
"key": [
{
"1": "def"
}
]
}
]
}
`))
j, err := JSONObj(reader)
# get the value of the first "key"
key := j.Get("root[1].key")