Skip to content

JSON‐LD‐star examles

Niklas Lindström edited this page Sep 11, 2024 · 3 revisions

Examples of JSON-LD-star

Triple Terms

Use @triple who's value MUST encode a single triple

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "value": {
    "@triple": {
      "@id": "bob",
      "age": 42
    }
  },
  "certainty": 0.8
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
[ :value <<( :bob :age 42 )>> ; :certainty 0.8e0 ] .

Generally @triple should not be used directly, as it corresponds to a triple term in RDF-star, which is intended to be used as part of a reifying triple.

Reifying Triples

JSON-LD-star supports reifying triples using the @reifies keyword.

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "@reifies": {
    "@id": "bob",
    "age": 42
  },
  "certainty": 0.8
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
<< :bob :age 42 >> :certainty 0.8e0 .

If the object containing the @reifies property has an explicit @id, it is used as the reifier.

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "@id": "r",
  "@reifies": {
    "@id": "bob",
    "age": 42
  },
  "certainty": 0.8
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
<< :bob :age 42 ~ :r >> :certainty 0.8e0 .

Reifying multiple triples

If the value of @reifies describes multiple triples, the reifier reifies each of those triples (in this way, it's not unlike a named graph).

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "@id": "r",
  "@reifies": {
    "@id": "bob",
    "name": "Bob",
    "age": 42
  },
  "certainty": 0.8
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
<< :bob :name "Bob" ~ :r >> .
<< :bob :age 42 ~ :r >> .
:r :certainty 0.8e0 .

Annotations

An annotation both reifies and asserts a triple.

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "@id": "bob",
  "age": {
    "@value": 42,
    "@annotation": {
      "certainty": 0.8
    }
  }
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
:bob :age 42 {| :certainty 0.8e0 |} .

Named reifiers for annotations

An annotation can also use a named reifier:

An annotation both reifies and asserts a triple.

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/"
  },
  "@id": "bob",
  "age": {
    "@value": 42,
    "@annotation": {
      "@id": "r",
      "certainty": 0.8
    }
  }
}

This describes the equivalent of the following Triple-star:

PREFIX : <http://example.org/>
:bob :age 42  ~ :r {| :certainty 0.8e0 |} .
Clone this wiki locally