-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
json_query() is reordering arrays. #200
Comments
Actually if I use [:2] instead of [0,1] I get the right answer but in the JSON path doc it doesn't mention that one method re-orders and the other doesn't. |
Reopening, this is a defect. The re-ordering you see with [0,1] is a consequence of how jsoncons removes duplicates from unions, but it should preserve the order. Thanks for reporting this. |
Fixed on master. You'll now see the expected |
Fix is in Release 0.142.0. |
When I call json_query() on an array it reorders the results. i.e if I have
JSON: {"book":[{"author":"C"},{"author":"B"},{"author":"A"}]}
query: $.book[0,1]
result [{"author":"B"},{"author":"C"}]
I get the correct contents but in the wrong order. I expected to get [{"author":"C"},{"author":"B"}]
Is there any way to make the query preserve the order ?
I wrote this code to test it ( I initially thought it may have been the print that was the issue )
The text was updated successfully, but these errors were encountered: