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

Document escaping rules for JsonPath patterns. #71

Open
curioustechizen opened this issue Jan 15, 2024 · 4 comments
Open

Document escaping rules for JsonPath patterns. #71

curioustechizen opened this issue Jan 15, 2024 · 4 comments

Comments

@curioustechizen
Copy link

I had a key in my JSON that included dots. I found from some other JsonPath libraries that escaping them requires you to include a bracket and single quotes.

val jsonPath = JsonPath.compile("$.['4.0.0']")

// as opposed to
val jsonPath = JsonPath.compile("$.4.0.0") 

The docs already mention "Bracket-notated key value accessor for JSON objects" but it was not obvious to me that this should be used for escaping purposes. I'm not aware if there are other escaping rules to be aware of.

It would be nice to add this to the docs. I am willing to open a PR if you think that this is a valid point to add to the docs.

@eygraber
Copy link
Owner

@DSinge what do you think?

@eygraber
Copy link
Owner

@curioustechizen can you point me to the other library that describes escaping them? I feel like this information has less to do with a specific library, and more to do with how JSONPath itself works, so I'd be hesitant to add that info to our documentation. I'm open to seeing what you can come up with though.

@curioustechizen
Copy link
Author

Sorry I did not mean that other libraries mention it in their documentation. I meant that there seems to not be agreement among libraries on how to escape dots. For example the answers to this SO question seem to indicate that there are 2 distinct syntaxes for escaping dots.

  1. The bracket and single-quotes syntax that I described in the issue description
  2. Another implementation (rest-assured) that omits the brackets

@eygraber
Copy link
Owner

I think the majority of implementations use the first approach, but I'll do some research and see if we should be calling this out.

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