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

Incorrect parsing of JSONPath query #2947

Open
tmoers opened this issue Apr 24, 2024 · 2 comments
Open

Incorrect parsing of JSONPath query #2947

tmoers opened this issue Apr 24, 2024 · 2 comments

Comments

@tmoers
Copy link

tmoers commented Apr 24, 2024

The following JSONPath selector fails

$.Sensors[?(@.SensorId=="left-id")].SensorName

to parse with the message

Unexpected character while parsing path query: "

Here is some minimal example to reproduce it:

var token = new Newtonsoft.Json.Linq.JValue(false);
token.SelectToken("$.Sensors[?(@.SensorId==\"left-id\")].SensorName", false);
@elgonzo
Copy link

elgonzo commented Apr 24, 2024

Note that Newtonsoft.Json implements (with slight inaccuracies) only a very old style/version of JSONPath described at https://goessner.net/articles/JsonPath. Old-ish JSONPath specification drafts (including relatively recent ones, like the one from 2020) only allowed single quotes in JSONPath expression. Hence the error message.

@tmoers
Copy link
Author

tmoers commented Apr 24, 2024

Oh, great.. I didn't realize. I just tried it and single quotes indeed works!

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