For the following Google JSON-LD structure ...
<script type="application/ld+json" id="datablock-1">
{
"@context": "http://schema.org/",
"@type": "Person",
"honorificPrefix": "Dr",
"givenName": "Albert",
"familyName": "Einstein",
"honorificSuffix": "PhD",
"jobTitle": "Professor of Physics",
"worksFor": [ {
"@type": "EducationalOrganization",
"department": "School of Science",
"parentOrganization": "Princeton University",
"address": [ {
"@type": "PostalAddress",
"streetAddress": "One Relativity Way",
"addressCountry": "USA" } ]
} ]
}
</script>
this HTML + JavaScript works:
<body>
<dl><dt>Big Ideas</dt><dd id="dd-1"></dd></dl>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var data = $("#datablock-1").html();
var json = JSON.parse(data);
var people = json["worksFor"];
for (i=0; i<=people.length; i++) {
var a=json["givenName"];
var b=json["familyName"];
var c=json["honorificSuffix"];
var d=json["worksFor"][i]["parentOrganization"];
$('#dd-1').append("<dd>"+a+" "+b+", "+c+". "+" "+d+"."+" "+"</dd>");
}
</script>
</body>
Now I need to reach one level deeper in the object and add information about "@type": "PostalAddress".
But this HTML + JavaScript does not work:
<body>
<dl><dt>Big Ideas</dt><dd id="dd-1"></dd></dl>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var data = $("#datablock-1").html();
var json = JSON.parse(data);
var people = json["worksFor"]["address"];
for (i=0; i<=people.length; i++) {
var a=json["givenName"];
var b=json["familyName"];
var c=json["honorificSuffix"];
var d=json["worksFor"][i]["parentOrganization"];
var e=json["worksFor"]["address"][i]["streetAddress"];
$('#dd-1').append("<dd>"+a+" "+b+", "+c+". "+" "+d+"."+" "+e+"</dd>");
}
</script>
</body>
What am I doing wrong? How to correct the error?
"@type": "PostalAddress"and key"address"and value"streetAddress"