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 comparison #145
Comments
It looks like value attribute is being compared lexicographically, because it's a string in your json. |
Maybe there should be a new option to configure comparison behavior? |
Is there any work around for this kind of situation as of now? |
I have also tried evaluating this on some online jsonpath evaluators (http://www.jsonquerytool.com/) , but i don't see this issue there. |
@kallestenflo I think option is a good idea. Option which switches between strict and best-effort comparisons. Strict comparisons always says I'v implemented best-effort comparison in my project using following scheme. First, every value is "interpreted" depending on its content (and cast accordingly): long-like become long, double-like become double, others are strings. Second, I use the following rules (top-down):
for GT, LT comparisons:
If jsons could not be corrected (type of value), then extract entire nodes
I think json path as a language lacks specification (Goessner's article is quite shallow to be one), and code (which evaluator is) should not be used as a specification. |
Or should it behave like JavaScript and differentiate between |
I like that. @jochenberger if you have time could you provide a couple of tests defining your expected behavior? I will try to fix it tonight. |
Where would I put those tests? Can I test the comparison alone? I'd expect the same semantics as in JavaScript.
|
However, if we did this consistently, comparisons will become somewhat nasty:
|
@kallestenflo btw, somewhere after 22d8a78 backward-incompatible change was introduced: 1 == '1' used to be true, but now (9258487) its false. |
…tring and number. Introduced === and !== to do type safe comparison.
This is fixed. |
I have the following json,
On the above json, i am trying to evaluate the following jsonpath expression,
Ideally the above expression should return an empty arraylist, however it is returning the following,
But if, i replace the "100" in the jsonexpression with any other value, say 98, then it is returning the correct output.
I am using the latest release of Jayway JsonPath .
The text was updated successfully, but these errors were encountered: