Forum Discussion
Yes, the “in” operator only tests to see if the property is in the object and not what it’s value might be. If the “child” property can be null in your data, you would have to check for that as well, by doing something like the following:
('child' in $) && $child && ('value' in $child)
Which is, admittedly, ugly. However, I’m not really sure how common this would really be, so I imagine most expressions would not have to do such a thing.
Still, this calls for some solution and I think we would prefer to modify the jsonPath() function to support default values instead of changing the hasOwnProperty() in a way that deviates from the standard.
The failure comes from “(‘child1’ in $.child)” since “$.child” is null, which matches the JavaScript behavior.