Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with finding values for key containing dot #85

Open
Vaibzz opened this issue Aug 4, 2020 · 4 comments
Open

Issue with finding values for key containing dot #85

Vaibzz opened this issue Aug 4, 2020 · 4 comments

Comments

@Vaibzz
Copy link

Vaibzz commented Aug 4, 2020

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

Please help.

@Jeffail
Copy link
Owner

Jeffail commented Aug 4, 2020

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())

@Vaibzz
Copy link
Author

Vaibzz commented Aug 4, 2020

Thanks @Jeffail . It works for me.

@Vaibzz Vaibzz closed this as completed Aug 4, 2020
@Vaibzz
Copy link
Author

Vaibzz commented Aug 5, 2020

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

@Vaibzz Vaibzz reopened this Aug 5, 2020
@Jeffail
Copy link
Owner

Jeffail commented Aug 5, 2020

No, in fact it should be faster if anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants