Jeffail/gabs

Outer array?

Closed this issue · 1 comments

k2xl commented

Can you provide examples of how to access values when top level json is an array?

i.e.

[{"hello":"friend"},{"good":"morning"}]

Maybe it'd be nice to be able to get a slice of jsonParsed? Or Be able to search via index like "0.hello"?

Hey @k2xl, to access a particular index you can use jsonParsed.Index(i), so for your example of "0.hello" you would need jsonParsed.Index(0).S("hello").

You can also iterate the elements in an array by accessing a slice of the children with jsonParsed.Children().