Fix array predicates in JSON path filters #4199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Fixes #3358
Description of the Change
We now use GSON as the mapping provider in addition to the JSON provider when using JsonPath. This allows array values to be built by JsonPath, where before it was unable to instantiate
List
.The only remaining non-GSON representation is JSONSmart, used by JsonPath to parse literals in the path expression. This is hardcoded, and unfortunately results in some inconsistencies noted below.
I also included some cleanup to eliminate
JsonParser
instances, as those are deprecated and we don't need them anyways.Possible Drawbacks
There will no doubt be some confusion over the exact behaviour of array predicates. Most predicates should just work as expected (e.g.,
anyof
, equality between numbers, etc), but specifically equality checks on numeric arrays are a problematic case that I don't think we can just fix. Such predicates will require the integral literals to be written with a decimal point so that JSONSmart treats them as doubles to match what the GSON mapping provider produces for the other operand. Using integers, the predicate will never match.Documentation Notes
Given this data set:
The following expressions will work to filter an array:
But this one will not match any elements since the integers inside the array are not considered equal to the floats used internally for the array being matched:
Release Notes
json.path
functions so that array predicates can be used.This change is