sajad torkamani

In a nutshell

JSON-LD (JavaScript Object Notation for Linked Data) is a data format much like JSON, except it includes a few standard properties that aim to provide additional context for the data and make it easier to find other related, linked data. Like JSON, JSON-LD is intended to be both human and machine-readable.

Here’s an example of JSON-LD data:

{
  "@context": "https://example.com/api/contexts/Note",
  "@id": "https://example.com/api/notes/2",
  "@type": "Note",
  "id": 2,
  "title": "My first note",
  "content": "What a life...",
  "createdAt": "2022-06-01T11:25:40+00:00",
  "updatedAt": "2022-06-01T11:25:40+00:00"
}

JSON-LD properties begin with the @ symbol. Here are the most common properties:

Properties

@context

This can be an absolute / relative IRI that contains the context definition:

{
  "@context": "https://json-ld.org/contexts/person.jsonld",
}

Or, it can be a JSON object that inlines the context definition:


{
  "@context": {
    "name": "http://schema.org/name",  ← This means that 'name' is shorthand for 'http://schema.org/name' 
    "image": {
      "@id": "http://schema.org/image",  ← This means that 'image' is shorthand for 'http://schema.org/image' 
      "@type": "@id"  ← This means that a string value associated with 'image' should be interpreted as an identifier that is an IRI 
    },
    "homepage": {
      "@id": "http://schema.org/url",  ← This means that 'homepage' is shorthand for 'http://schema.org/url' 
      "@type": "@id"  ← This means that a string value associated with 'homepage' should be interpreted as an identifier that is an IRI 
    }
  }
}

@id

The @id is the unique IRI that identifies the node. Unique identifiers are an essential component of linked data.

@type

Specifies the type of the node. This can be an IRI:

{
  ...
  "@id": "http://example.org/places#BrewEats",
  "@type": "http://schema.org/Restaurant",
  ...
}

Or a term defined in the active context:

{
  "@context": {
    ...
    "Restaurant": "http://schema.org/Restaurant", 
    "Brewery": "http://schema.org/Brewery"
  },
  "@id": "http://example.org/places#BrewEats",
  "@type": [ "Restaurant", "Brewery" ],
  ...
}

Key terms / jargon

TermDescription
IRIInternationalized Resource Identifier that uniquely identifies a node in a Linked Data system.
IRI dereferncingLooking up the definition of a term by using its IRI.

Sources

Tagged: Misc

Leave a comment

Your email address will not be published. Required fields are marked *