I have the below JavaScript object.
If myobject holds the below content, how do I check if a particular key is available or not?
{
"AccountNbr": "1234567890123445",
"AccountName": "Test Bob",
"Address": {
"addressId": 1234,
"line1": "Sample Line 1",
"line2": "Sample Line 2",
"city": "Sample City",
"state": "State"
}
}
For example, to check if key "AccountNbr" is available. I used the below statement and it returned true.
"AccountNbr" in myobject
and it returned true. If I have to check if key "addressId" is available, I used the below statement and it returns false, though the key is available.
"Address.addressId" in myobject
The above statement always returns false, though addressId is available. Is there any other alternative to check if addressId is available?
I also tried giving myobject.Address.addressId and it always returned false, though the key is available.