DDI-CDI & JSON-LD

DDI-CDI Dagstuhl Seminar – 19-24 Sept. 2021

Pierre-Antoine Champin
MOSAICrOWN logo   This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 825333 

RDF in one slide

An example RDF graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu'

JSON-LD in the RDF ecosystem

This figure shows the different parts of the eco-system: RDF abstract syntax is surrounded by RDF semantics and RDF abstract syntaxes. SPARQL, SHACL and others are linked to the abstract syntax. RDF-S, OWL and others are linked to the semantics.

DDI-CDI to JSON-LD?
(short answer)

But there is more to it...

Straightforward JSON-LD serialization

An example RDF graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu'
[
  {
    "@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" }
    ]
  }
]

A more idiomatic JSON representation

An example RDF graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu'
{
  "id": "#pa",
  "type": "Person",
  "name": "Pierre-Antoine Champin",
  "worksFor": {
    "id": "#w3",
    "type": "Organization",
    "name": "World Wide Web Consortium"
  }
}

The four main algorithms of JSON-LD

Workflow representing the 4 main algorithms of JSON-LD: toRdf and fromRdf (between RDF graphs and the expanded form of JSON-LD), and compact and expand (between the expanded and the compact forms of JSON-LD). compact and expand use an additional input called the context.

Benefit of the compact form

A compact JSON-LD document can be used from different points of view: either as representing an RDF graph, or as representing 'plain' JSON data

Keeping track of the context

The JSON-LD context can be

What's in a context (1)

Mapping from short names to IRIs (or JSON-LD keywords)

An example RDF graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu'
{
  "@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"
} }

What's in a context (2)

See

What's not in a context

JSON-LD is not a general purpose transformation language.

DDI-CDI to JSON-LD?
(longer answer)

Going further: RDF-star

A community effort to extend RDF

with the ability to make statements about statements.

See

An example RDF-star graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu' since February 2021

JSON-LD-star

An example RDF-star graph showing a person named 'Pierre-Antoine Champin' working for an organization named 'World Wide Web Consortimu' since February 2021
{
  "id": "#pa",
  "type": "Person",
  "name": "Pierre-Antoine Champin",
  "worksFor": {
    "@annotation": {
      "startDate": "2021-02-21"
    },
    "id": "#w3",
    "type": "Organization",
    "name": "World Wide Web Consortium"
  }
}

See

Any question?

Appendix

Framing

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.

See

What's in a context (example)

Desambiguation of the values (node type, datatype, langue)

An example RDF graph showing the #w3c was founded by #tbl on 1994-10-01, and that its slogan is 'Leading the web to its full potential'

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"
}