https://bz.apache.org/bugzilla/show_bug.cgi?id=65681

--- Comment #7 from Felix Schumacher <[email protected]> ---
(In reply to Philippe Mouawad from comment #6)
> (In reply to Felix Schumacher from comment #5)
> > Created attachment 38091 [details]
> > Set default value when a null value is found by the JSON path expression
> > 
> > I added test cases for the new behaviour.
> Thanks for investigation and fix.
> > 
> > I am not sure, whether the handling of multiple results is correct or
> > intended.
> > 
> > Consider the structure '[{"c": null}, {"c": "abc"}]' and the path '$[*].c'
> > with a default value of "NONE". JSON Path will lead to a result of '[null,
> > "abc"]' which we will enhance to '["NONE", "abc"]'. (That sounds valid)
> > 
> Agreed
> 
> > But, what if the user intended to give a default value for a complete absent
> > result? Like using an expression '$.listOfValues' on the above structure and
> > an expected default value '[1, 2, 3]'? In that case the new implementation
> > would yield unexpected results.
> 
> I don't get the case.
> What will be the result vs the previous behaviour ? Was it more consistent
> before ? 

Well, when no result is found, we get the default value, when we get a list
with non null values, we get the (probably) intended result, but when we get a
list with null and non null values, it might be unexpected:

$.listOfValues    |   result
------------------------------
null              |  [1, 2, 3]
""                |  ""
[4, 5]            |  [4, 5]
[1, null]         |  [1, [1, 2, 3]]

But while writing this, I wonder, whether the default value is always a string
and therefore the results would be "[1, 2, 3]"; ""; [4, 5]; [1, "[1, 2, 3]"]

I hope that makes my concerns clearer (note, I haven't checked the old
behaviour)

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to