-
Notifications
You must be signed in to change notification settings - Fork 26
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
Does JSONPath guarantee an ordered list for multiple responses? #3
Comments
Another interesting question is behaviour of slice with negative step. In Python negative step reverses iteration, like this:
I decided that my JsonPath implementation should always return results in depth-first mode, so it will return
|
(Thanks for the negative step idea, I added three more queries, e.g. https://cburgmer.github.io/json-path-comparison/results/array_index_slice_negative_step.html) |
We should probably review the need for https://github.com/cburgmer/json-path-comparison/blob/master/src/canonical_json.py which re-orders results before comparison. |
I thought alot about this case recently and concluded that we should split results comparation into several levels:
Thus we can have several different consensuses for the same result set:
I don't see any reliable way to detect non-deterministic order (maybe just running the tests repeatedly, but that's time consuming and doesn't give any garantee), so I suggest just set it as a flag for those libraries that showed non-deterministic order at least once. We can use similar approach with errors, configuring result post-processing for each library to detect following states:
In this case we can calculate error consensus more precisely, irrespective of implementation details. |
I like your thinking. For the error status that will help us navigate around the different levels of expressiveness. |
Just to quote ECMA-404 "The JSON Data Interchange Syntax" here:
|
I think the next steps we should do next are:
|
Happy to improve! Would you mind opening new issues for those points other than result ordering? As for the ordering: |
I don't think we can detect "problematic" queries. "Problematic" are the implementations, and later we will find the way to detect approaches for different libraries. But it should be quite separate investigation. |
Agree. We do know the queries that are disputed though: anything with recursive descent ( |
I would close this issue for now and track pending open questions separately:
|
Not all implementations seem to return results in order of occurrence (depth-first) for recursive descending queries in the JSON structure, e.g. Java (com.github.jsurfer) for https://cburgmer.github.io/json-path-comparison/results/recursive_key.html and https://cburgmer.github.io/json-path-comparison/results/recursive_wildcard.html).
Is this a bug or just not guaranteed?
The text was updated successfully, but these errors were encountered: