Jeffail/gabs

Issue with finding values for key containing dot

Opened this issue · 4 comments

I am facing issues while fetching keys having "." in them.
Example code- https://play.golang.org/p/3vpVXQvA6fv

Please help.

Hey @Vaibzz, from the docs:

Because the characters '~' (%x7E) and '.' (%x2E) have special meanings in gabs paths, '~' needs to be encoded as '~0' and '.' needs to be encoded as '~1' when these characters appear in a reference key.

Your options are to encode dots as ~1 in your path arguments like this:

log.Println(jsonParsed.Path("prediction~1prediction_confidence").Data())

Or, alternatively, you can use the Search method which is an explicit slice of path segments:

log.Println(jsonParsed.Search("prediction.prediction_confidence").Data())

Thanks @Jeffail . It works for me.

@Jeffail Is there any performance degradation in Search method as compared to Path method?

No, in fact it should be faster if anything.