When evaluating an expression like foos[?foo == 'nobar'].bar on the below example JSON, the returned value is [] rather than NULL. It returns an empty result list rather than a null value.
The library JsonContext::theJsonPathExpressionShouldHaveResult and JsonContext::theJsonPathExpressionShouldNotHaveResult() only check for NULL value when asserting whether there is a result passing the above expression.
This PR changes the evaluation to also check for an empty array and / or null value.
When evaluating an expression like
foos[?foo == 'nobar'].bar
on the below example JSON, the returned value is[]
rather thanNULL
. It returns an empty result list rather than a null value.The library
JsonContext::theJsonPathExpressionShouldHaveResult
andJsonContext::theJsonPathExpressionShouldNotHaveResult()
only check for NULL value when asserting whether there is a result passing the above expression.This PR changes the evaluation to also check for an empty array and / or null value.
Example JSON:
{ "foo": "bar", "footrue": true, "foofalse": false, "foonull": null, "fooint": 1337, "foos": [ {"foo": "bar", "bar": "bar"}, {"foo2": "bar2"} ], "fooo": { "foo": "bar" }, "fooarray": [ "bar1", "bar2" ] }