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

Support for escaping dots in key #324

Open
arielpontes opened this issue Feb 7, 2024 · 1 comment
Open

Support for escaping dots in key #324

arielpontes opened this issue Feb 7, 2024 · 1 comment

Comments

@arielpontes
Copy link

Consider the following dictionary (which is also valid JSON):

 my_dict = {"props": {"data.value": [{"name": "Ariel"}]}}

How can I access the value "Ariel" here? I tried jmespath.search("props.data.value[0].name") and jmespath.search("props.data\.value[0].name") but none of these options worked. In the documentation I didn't find any information regarding customizing the dot notation (perhaps using double-underscore instead, although that could also be found inside a key). Is there any way to handle such a situation?

If not, shouldn't there be? Escaping dots within keys with backslashes is the most natural solution that comes to my mind.

@ftnt-dspille
Copy link

ftnt-dspille commented Feb 7, 2024

You can put the key in quotes to escape the period, like this jmespath.search('props."data.value"[0].name')

I'm assuming the docs that reference using quotes to escape the symbol is this link - https://jmespath.org/specification.html#raw-string-literals

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