JSON provides a simple representation of the key/value properties of an object:
{
"id": "http://example-one.com/foo",
"title": "bar",
"published": "2013-01-01T12:00:00Z"
}
However, someone else might have chosen to use different names for those properties:
{
"id": "http://example-two.com/foo",
"name": "baz",
"date_published": "2013-01-02T12:00:00Z"
}
Without needing anyone to change their data schema - apart from a backwards-compatible addition of one line - JSON-LD allows each data publisher to map their local property names to the URLs and data types of a shared ontology.
The mapping from local property names to ontology URLs is provided by a JSON-LD context document, linked from the data using a @context attribute:
{
"@context": "context-1.jsonld",
"id": "http://example-one.com/foo",
"title": "bar",
"published": "2013-01-01T12:00:00Z"
}
{
"@context": "context-2.jsonld",
"id": "http://example-two.com/foo",
"name": "baz",
"date_published": "2013-01-02T12:00:00Z"
}
{
"@context": {
"id": {
"@id": "http://schema.org/url",
"@type": "@id"
},
"title": "http://schema.org/name",
"published": {
"@id": "http://schema.org/datePublished",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
}
}
}
{
"@context": {
"id": {
"@id": "http://schema.org/url",
"@type": "@id"
},
"name": "http://schema.org/name",
"date_published": {
"@id": "http://schema.org/datePublished",
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
}
}
}
A parser can then combine the context document and the actual data to produce linked data:
{
"http://schema.com/url": "http://example-one.com/foo",
"http://schema.org/name": "bar",
"http://schema.org/datePublished": "2013-01-01T12:00:00Z"
}
{
"http://schema.com/url": "http://example-two/foo",
"http://schema.org/name": "baz",
"http://schema.org/datePublished": "2013-01-02T12:00:00Z"
}
<http://example-one.com/foo>
<http://schema.org/name> "bar" ;
<http://schema.org/datePublished> "2013-01-01T12:00:00Z"^^xsd:dateTime .
<http://example-two.com/foo>
<http://schema.org/name> "baz" ;
<http://schema.org/datePublished> "2013-01-02T12:00:00Z"^^xsd:dateTime .