I am getting below json data:
{
  "ID": [
    "The i d field is required."
  ],
  "terms_condition": [
    "The terms condition field is required."
  ]
}
and stored in variable:
var DataJson = data.responseText;
var Json = JSON.parse(DataJson);
var IdError = Json.ID[0];
var TermsConditionError = Json.terms_condition[0];
Now I am getting this error Uncaught TypeError: Cannot read property '0' of undefined when ID is not exists
I have tried with this example to prevent error handling.
if (typeof Json.ID[0] !== 'undefined') {
    alert('validation message found');
} else {
    alert('validation message not found');
}
but this is not working any idea what i am doing wrong?
Thanks.
 
     
    