Closed dnj12345 closed 1 year ago
Different JSONPath implementations have different understandings of applying a filter to an object.
(1) Some don't allow it at all, only to arrays (2) Some apply the filter to the object itself (following Jayway, jsoncons did this up until version 0.161.0) (3) Some apply the filter to the value part of the object's name value pairs (jsoncons does this since version 0.161.0.)
For the three websites that you checked, the first exhibits the behavior described in (2), and the second and third exhibit the behavior described in (3).
To make your query work with the second and third websites (and jsoncons since 0.161.0), rewrite it as
$..bicycle[?(@.type == 'tubular')]
ok. Thanks for the clarification.
Not sure if it makes sense to add a note in the documentation.
I recently upgraded my project to use the latest jsoncons version
v0.169.0
. Since then JSON path filter expressions are not working correctly. The same JSON path expression with filter works fine with jsoncons versionv0.106.0
. I've tested my expressions at various websites with mixed results: javainuse.com/jsonpath (works), jsonpath.com (fails), jsonquerytools.com (fails)As you can see, the expression yields results. Here are the results for v0.169.0
Here's my test program.
The two versions were tested on two different containers because of the upgrade to the container and compilers etc. Could not build older versions with the newer compiler etc.
v0.169.0:
v0.106.0: