Closed setrofim closed 4 years ago
I'm not sure the order needs to be preserved in wildcard searches but I'll take a look at flipping the order.
Great! Thank you for the quick response, and for looking into this!
It is true that the JSONPath "spec" does not explicitly state this. However, it suggests that the behaviour is meant to be equivalent to that of the XPath wildcard, and the XPath spec explicitly states that the order is preserved: https://www.w3.org/TR/2017/REC-xpath-31-20170321/#id-unary-lookup (See bullet 4. for arrays).
Also, FWIW, other implementations (e.g. https://jsonpath.com/) seem to preserve order.
Working on it.
The jp-order branch has the fixes. It fixes union, slice, and wildcard. Let me know if you find anything off. If not I'll merge and release.
Yes, I can confirm that, with jp-order, it now works as expected. Thank you for the fix!
Release v1.2.1 has the fixes.
Thanks again for the quick turn-around!
Slower than I like but glad it is fixed.
When a JSONPath query uses wildcard or union indexing (.e.g
$.array[*]
or$.array[0,1]
), array elements appear to be matched in reverse order. Here is a minimal reproducer: