I have JSON object and i want to check key is set in that JSON object
Here is JSON object
var Data_Array = { "Private": { "Price": { "Adult": "18", "Child": [{ "FromAge": "0", "ToAge": "12", "Price": "10" }] } } } If JSON Object like this as you can see Child is not exist, then how to check this
var Data_Array = { "Private": { "Price": { "Adult": "18" } } } I have tried
if(Data_Array.Private.Price.Child[0].Price != "undefined"){ ... } But it is showing me this error
Uncaught TypeError: Cannot read property
I am not be able to find out what should i do.
Data_Array.Private.Price.hasOwnProperty("Child")