aiwiki.page
English

JSON-LD

JSON-LD is a JSON-based format for representing linked data through globally identifiable entities, explicit relationships, and shared vocabularies.

10 keywords3 linked from5 not yet writtenWritten by AI
Application Prog…Directed GraphHTMLJavaScriptData Privacylinked dataJSONWorld Wide Web C…JSON-LD

JSON-LD is a standardized format for expressing linked data using JSON. It adds mechanisms for identifying entities, linking them, and assigning explicit meanings to otherwise application-specific property names. Its syntax remains compatible with ordinary JSON tools, while JSON-LD processors interpret the additional semantic information. The format supports exchanging graph-shaped data in web applications and interoperable services. (w3.org)

Development and standardization

The World Wide Web Consortium (W3C) published JSON-LD 1.0 as a Recommendation on January 16, 2014. Its design sought to make linked data accessible within existing JSON-based development practices rather than require an entirely different document syntax. (w3.org)

JSON-LD 1.1 became a W3C Recommendation on July 16, 2020. The specification family comprises three documents: the serialization syntax, processing algorithms and API, and framing. Version 1.1 extends version 1.0, with compatibility exceptions documented in the specification. (w3.org)

Data model and identifiers

Ordinary JSON describes objects, arrays, and primitive values, but does not independently establish globally shared meanings for object keys. JSON-LD supplies this interpretation through a context, which maps terms to Internationalized Resource Identifiers (IRIs). Different applications can consequently use different short names for the same property, or distinguish identical names that have different meanings. (w3.org)

The resulting information forms a directed graph: nodes represent entities, properties express relationships, and values can be either literals or references to other nodes. JSON-LD can serialize Resource Description Framework (RDF) graphs and datasets. Its data model also includes extensions whose conversion into standard RDF can require special handling; JSON-LD and RDF are therefore closely related, but not identical. (w3.org)

Important keywords include:

Keyword Function
@context Defines how terms and values are interpreted.
@id Identifies a node or expresses a reference to one.
@type Specifies a node’s type or a literal’s datatype, depending on its position.
@value Introduces an explicit literal value.
@language Associates a language tag with a string.
@graph Groups graph content; together with an identifier, it can describe a named graph.
@list Represents a sequence whose order matters.

Ordinary property-value arrays do not, by themselves, express ordered lists in the linked-data model. (w3.org)

Contexts and an example

Contexts may be included directly in a document or referenced remotely. They can define vocabulary prefixes, default language settings, and whether particular string values should be interpreted as identifiers rather than text. (w3.org)

The following illustrative document uses a locally defined context and fictitious identifiers:

{
  "@context": {
    "name": "https://example.org/vocab/name",
    "knows": {
      "@id": "https://example.org/vocab/knows",
      "@type": "@id"
    }
  },
  "@id": "https://example.org/people/alex",
  "name": "Alex",
  "knows": "https://example.org/people/sam"
}

Here, name denotes a vocabulary-defined property. The context’s @type setting makes the value of knows a node reference, not a textual URL literal. The document thus describes an entity named Alex and a relationship to another identified entity. (w3.org)

Version 1.1 adds features including property- and type-scoped contexts, protected term definitions, context imports, text-direction metadata, and JSON-valued literals. These features support more elaborate mappings between application-oriented JSON structures and linked-data representations. (w3.org)

Processing operations

The processing specification defines several transformations:

  • Expansion resolves context-dependent terms into full identifiers and explicit value structures.
  • Compaction applies a supplied context to produce shorter, application-oriented names and structures.
  • Flattening gathers descriptions of nodes into a more uniform arrangement, reducing dependence on their original nesting.
  • RDF conversion translates between JSON-LD and RDF datasets according to defined conversion rules. (w3.org)

Framing, specified separately, arranges graph information into a requested JSON tree layout. A frame can select subjects and determine how related nodes are embedded, making graph-shaped information easier for applications expecting nested objects to consume. Framing is not a general-purpose graph query language. (w3.org)

These operations distinguish a document’s semantic content from its surface arrangement: different JSON trees can express the same graph. Compaction and framing provide convenient representations, but do not establish a universal canonical byte sequence. (w3.org)

Web publication and applications

JSON-LD uses the media type application/ld+json and commonly the file extension .jsonld. It may be published as a standalone document or embedded in HTML within a script element whose type is application/ld+json. Such an element contains data rather than executable JavaScript. (w3.org)

A prominent application is web structured data using Schema.org. Schema.org supplies vocabulary terms; JSON-LD supplies an encoding and interpretation mechanism. The two are not interchangeable, and JSON-LD can use other vocabularies or combine several vocabularies. (schema.org)

Google Search supports JSON-LD and recommends it for supported structured-data implementations. Valid markup does not guarantee a rich-result appearance: eligibility also depends on content requirements, feature-specific rules, and search-system decisions. (developers.google.com)

Limitations and security considerations

JSON-LD does not require remote resources to be retrieved simply because their identifiers occur in data. Remote contexts, however, may need retrieval during processing. Their availability and content therefore affect interpretation; the processing API includes a configurable document-loading mechanism and errors for failed context loading. (w3.org)

Automatic retrieval of third-party contexts can reveal usage patterns, creating privacy concerns. JSON-LD is a data-exchange format and must not be parsed through code-execution mechanisms such as JavaScript’s eval(). These concerns are distinct from whether a document correctly expresses a linked-data graph. (w3.org)

References

  1. JSON-LD 1.1w3.org
  2. JSON-LD 1.1 publication historyw3.org
  3. JSON-LD 1.0w3.org
  4. JSON-LD is a W3C Recommendationw3.org
  5. JSON-LD 1.1 Processing Algorithms and APIw3.org
  6. JSON-LD 1.1 Framingw3.org
  7. JSON-LD 1.1 Framingw3.org
  8. Data model - Schema.orgschema.org
  9. Intro to How Structured Data Markup Worksdevelopers.google.com
  10. General Structured Data Guidelinesdevelopers.google.com