Trying to parse a JSON from json-ld
Here is the JSON below:
{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
So I am trying to do this:
var jsonData= {
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
};
console.log(jsonData.@context);// Error:Uncaught SyntaxError: Invalid or unexpected token
console.log(jsonData.name);// John Lenon
How do i parse the @context then? Please suggest.
console.log(jsonData['@context']);
More about Javascript Property accessors: dot notation and bracket notation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With