subject predicate object
But there is more to it...
[
{
"@id": "https://json-ld.org/playground/#pa",
"@type": [ "http://schema.org/Person" ],
"http://schema.org/name": [
{ "@value": "Pierre-Antoine Champin" }
],
"http://schema.org/worksFor": [
{ "@id": "https://json-ld.org/playground/#w3" }
]
},
{
"@id": "https://json-ld.org/playground/#w3",
"@type": [ "http://schema.org/Organization" ],
"http://schema.org/name": [
{ "@value": "World Wide Web Consortium" }
]
}
]
{
"id": "#pa",
"type": "Person",
"name": "Pierre-Antoine Champin",
"worksFor": {
"id": "#w3",
"type": "Organization",
"name": "World Wide Web Consortium"
}
}
The JSON-LD context can be
"@context": {...},"@context": "http://example.org/my-context.jsonld",Link headerMapping from short names to IRIs (or JSON-LD keywords)
{
"@context": {
"id": "@id",
"type": "@type",
"Person": "http://schema.org/Person",
"name": "http://schema.org/name",
"worksFor": "http://schema.org/worksFor",
"Organization": "http://schema.org/Organization"
},
"id": "#pa",
"type": "Person",
"name": "Pierre-Antoine Champin",
"worksFor": {
"id": "#w3",
"type": "Organization",
"name": "World Wide Web Consortium"
} }
JSON-LD is not a general purpose transformation language.
{
"id": "#pa",
"type": "Person",
"name": "Pierre-Antoine Champin",
"worksFor": {
"@annotation": {
"startDate": "2021-02-21"
},
"id": "#w3",
"type": "Organization",
"name": "World Wide Web Consortium"
}
}
Actually, to go from the ugly JSON-LD serialization to the idiomatic one in the introductory example, the compaction algorithm is not sufficient.
The JSON-LD specification defines another algorithm called framing, which is complementary to compaction.
In a nutshell, compaction works at the level of individual attributes, while framing can reorganize the structure of the whole document.
Desambiguation of the values (node type, datatype, langue)
NB: also notice that the "short names" do not need to be similar to the IRI.
{
"@context": {
"id": "@id",
"s": "http://schema.org/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"founder": { "@id": "s:founder",
"@type": "@id" },
"founded": { "@id": "s:foundingDate",
"@type": "xsd:date" },
"motto": { "@id": "s:slogan",
"@language": "en" }
},
"id": "#w3c",
"founder": "#tbl",
"founded": "1994-10-01",
"motto": "Leading the web to its full potential"
}