jmespath.py
jmespath.py copied to clipboard
JEP-19 Evaluation of Pipe Expressions
Sub Expression
The specification for sub-expression outlines how it should behave in pseudocode:
left-evaluation = search(left-expression, original-json-document)
result = search(right-expression, left-evaluation)
However, this is incorrect, as many compliance tests expect the result to be null when the left-hand-side evaluates to null.
So, the real pseudocode shoud in fact be:
left-evaluation = search(left-expression, original-json-document)
if left-evaluation is `null` then result = `null`
else result = search(right-expression, left-evaluation)
Pipe Expression
However, it seems intuitive for pipe-expression to behave as is specified by the pseudocode above.
left-evaluation = search(left-expression, original-json-document)
result = search(right-expression, left-evaluation)
Which means that the evaluation should still happens if the left-hand-side is null.
Summary
This PR introduces a new compliance test that outlines the following expression: search ( `null` | [@], {} ) -> [ null ] in the hope to standardize the exact behaviour of pipe expressions.