tk42
9 years agoNew Contributor III
hasOwnProperty() and fields containing special characters
Given the object:
{
"Errors" : {
"$.Field_1" : "Too many characters.",
"Field_2" : "Too few characters."
}
}
The following expressions yield different results:
$Errors.hasOwnProperty('$.Field_1') ==> false
$Errors.hasOwnProperty('Field_2') ==> true
We tried all manner of escaping the “$.Field_1” to no avail, before finding a different path that does not require the “hasOwnProperty” call.
But I am still curious if this is an issue of not escaping the argument correctly, or a bug in the hasOwnProperty() implementation?
Thanks,
TK