Forum Discussion
Hello Sanam, could you please share the use case on connecting to SQL server from a Python script when there is a SQL Server-specific snap pack and the JDBC snap pack to connect to SQL Server?
the “in” operator return true if there a property with null value. and if you further check for sub-child it errors out.
example 1:-
$:{
child:null
}example 2:-
$: {
child: {
child1: “some value”
}$.hasOwnProperty() helps in filtering this type of use cause while “in” operator return true for example-1, (‘child’ in $) and will generate an error “Requires an Array or Object in-the-Right-hand-side” for example-1 if you try this expression: (‘child’ in $) && (‘child1’ in $.child) but it will work for example 2.
get() method works for both the case in order to filter out property based on null try this: ($.get(“child”) != null) && ($.child.get(“child1”) != null). Is “in” operator (shorthand for get()) bugged ?
Get method:
Sorry for bad formatting.
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.
- nganapathiraju8 years agoFormer Employee
Your expression should be
'child' in $ && 'child1' in $child
The above will return true is child1 exists in child. Its not $.child
Hope that makes sense.
Related Content
- 2 years ago
- 8 years ago
- 2 years ago
- 4 years ago