cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

hasOwnProperty will be deprecated?

aleung
Contributor III

I am getting the following warning during pipeline execution, where can I find more details? What is the suggested actions?

WarningPassing: a JSON-Path to hasOwnProperty() is not supported and will fail in the future
ResolutionUse: hasOwnProperty() for each component of the path

1 REPLY 1

tstack
Former Employee

The hasOwnProperty() documentation has some notes on the change. Basically, the method behaved differently than how it is defined in JavaScript, which the expression language is based around. Since we want to follow the existing standard to avoid surprising people familiar with JavaScript, weโ€™re issuing the warning and trying to move people away from the non-standard usage.

In your case, it sounds like youโ€™re testing for a JSON-Path and not a plain property name. If youโ€™re only testing for a property directly in the object (e.g. $name) and not a descendant (e.g. $foo.bar), you can just remove the dollar sign. If you are drilling down into sub-objects, then youโ€™d need to check for each intermediate object using hasOwnProperty, the โ€˜inโ€™ operator, or the โ€˜get()โ€™ method. In the near future, weโ€™ll add support for specifying a default value in the jsonPath() function to make this case easier.