contact1 : {name: "Kesh", relation: "Mother", number: "9819269972"}
this is particular data is part of a bigger json data. I am accessing it via JSONArrayName.contact1. How do i access name, relation and number now?
var obj, dbParam, xmlhttp, myObj, x, txt = "";
obj = { "table":"Successful", "limit":20 };
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myObj = JSON.parse(xmlhttp.responseText);
console.log(myObj);
//console.log(myObj[0]);
document.getElementById("userId").innerHTML = myObj.id;
document.getElementById("DOB").innerHTML = myObj.dob;
document.getElementById("bloodGroup").innerHTML = myObj.bloodGroup;
document.getElementById("aadhar").innerHTML = myObj.aadharCard;
document.getElementById("allergies").innerHTML = myObj.allergies;
document.getElementById("insurances").innerHTML =
myObj.insuranceDetails;
var contact1 = myObj.contact1;
console.log(contact1);
}
console output: myobj:
{id: "123456", insuranceDetails: null, allergies: null, bloodGroup: "A", gender: "Female", contact1: {name: "Kesh", relation: "Mother", number: "9819269972"}, contact2: {name: "Kesh", relation: "Mother", number: "9819269972"}}
contact1:
{name: "Kesh", relation: "Mother", number: "9819269972"}

xmlhttp.responseTextvariable is correct JSON?