Closed leonj1 closed 2 years ago
@leonj1 just to exclude the most obvious reason, the JSON you posted above has a typo: "age": 2"
instead of "age": 2
.
Did you get the unexpected result also with a valid JSON?
I don't have handy the Go library, but on https://gjson.dev/ the query {#.name,#.age}
returns as expected:
{"name":["frank","annie"],"age":[2,18]}
Dang! I missed that. Thanks!
Is it possible to select just the name and age from this json?
[ { "name": "frank", "dob": "foo", "age": 2" }, { "name": "annie", "dob": "bar", "age": 18 } ]
Using this, the array returns 2 Null Results
results := gjson.GetMany(input, "#.name", "#.age")