This specification defines a set of algorithms for programmatic transformations of JSON-LD documents. Restructuring data according to the defined transformations often dramatically simplifies its usage. Furthermore, this document proposes an Application Programming Interface (API) for developers implementing the specified algorithms.
This document has been under development for over 31 months in the JSON for Linking Data Community Group. The document has been transferred to the RDF Working Group for review, improvement, and publication along the Recommendation track. The specification has undergone significant development, review, and changes during the course of the last 31 months.
There are several independent interoperable implementations of this specification. There is a fairly complete test suite [[JSON-LD-TESTS]] and a live JSON-LD editor that is capable of demonstrating the features described in this document. While there will be continuous development on implementations, the test suite, and the live editor, they are believed to be mature enough to be integrated into a non-production system at this point in time. There is an expectation that they could be used in a production system within the next two months.
There are a number of ways that one may participate in the development of this specification:
Changes since the 10 September 2013 Candidate Recommendation:
This document is a detailed specification of the JSON-LD processing algorithms. The document is primarily intended for the following audiences:
To understand the basics in this specification you must first be familiar with JSON, which is detailed in [[!RFC4627]]. You must also understand the JSON-LD syntax defined in [[!JSON-LD]], which is the base syntax used by all of the algorithms in this document. To understand the API and how it is intended to operate in a programming environment, it is useful to have working knowledge of the JavaScript programming language [[ECMA-262]] and WebIDL [[WEBIDL]]. To understand how JSON-LD maps to RDF, it is helpful to be familiar with the basic RDF concepts [[RDF11-CONCEPTS]].
The JSON-LD Syntax specification [[!JSON-LD]] defines a syntax to express Linked Data in JSON. Because there is more than one way to express Linked Data using this syntax, it is often useful to be able to transform JSON-LD documents so that they may be more easily consumed by specific applications.
JSON-LD uses
There are four major types of transformation that are discussed in this document: expansion, compaction, flattening, and RDF serialization/deserialization.
The algorithm that removes
To get an idea of how context and data structuring affects the same data,
here is an example of JSON-LD that uses only
The next input example uses one
Note that both inputs are valid JSON-LD and both represent the same
information. The difference is in their
expand
operation) against the above examples results in the following output:
Note that in the output above all
While
For example, assume the following expanded JSON-LD input document:
Additionally, assume the following developer-supplied JSON-LD
Running the Compaction Algorithm
(compact
operation) given the context supplied above against the JSON-LD input
document provided above would result in the following output:
Note that all http://xmlns.com/foaf/0.1/name
to name
, it
could also have been mapped to any other term provided by the developer.
While expansion ensures that a document is in a uniform structure,
flattening goes a step further to ensure that the shape of the data
is deterministic. In expanded documents, the properties of a single
For example, assume the following JSON-LD input document:
Running the Flattening algorithm
(flatten
operation) with a context set to
Note how in the output above all properties of a _:t0
.
To make it easier for humans to read or for certain applications to process it, a flattened document can be compacted by passing a context. Using the same context as the input document, the flattened and compacted document looks as follows:
Please note that the result of flattening and compacting a document
is always a @graph
member that represents the
JSON-LD can be used to serialize RDF data as described in [[RDF11-CONCEPTS]]. This ensures that data can be round-tripped to and from any RDF syntax without any loss in fidelity.
For example, assume the following RDF input serialized in Turtle [[TURTLE]]:
Using the Serialize RDF as JSON-LD algorithm a developer could transform this document into expanded JSON-LD:
Note that the output above could easily be compacted using the technique outlined in the previous section. It is also possible to deserialize the JSON-LD document back to RDF using the Deserialize JSON-LD to RDF algorithm.
All examples and notes as well as sections marked as non-normative in this specification are non-normative. Everything else in this specification is normative.
The keywords MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this specification are to be interpreted as described in [[!RFC2119]].
There are two classes of products that can claim conformance to this
specification:
A conforming
A conforming
The algorithms in this specification are generally written with more concern for clarity
than efficiency. Thus,
Implementers can partially check their level of conformance to this specification by successfully passing the test cases of the JSON-LD test suite [[JSON-LD-TESTS]]. Note, however, that passing all the tests in the test suite does not imply complete conformance to this specification. It only implies that the implementation conforms to aspects tested by the test suite.
This document uses the following terms as defined in JSON [[!RFC4627]]. Refer to the JSON Grammar section in [[!RFC4627]] for formal definitions.
@context
where the value, or the @id
of the
value, is @value
, @list
, or
@set
is set to Furthermore, the following terminology is used throughout this document:
_:
.@context
@value
, @list
,
or @set
keywords, or@graph
and @context
.@value
member.@list
member.@set
member.When processing a JSON-LD data structure, each processing rule is applied
using information provided by the
The
When processing, the
First we prepare a new
If @context
key of the top-level object in the
retrieved JSON-LD document. If there's no such key, an invalid remote context has
been detected. Otherwise, we process
If @base
, @vocab
, and @language
.
These are handled before any other keys in the @base
is
ignored when processing remote contexts.
Then, for every other key in
Finally, we return result as the new
This algorithm specifies how a new
base
option of a JSON-LD API Implementation overrides the recursive context inclusion
error has been detected and processing is aborted;
otherwise, add context to remote contexts.loading remote context failed
error has been detected and processing is aborted. If the dereferenced document has no
top-level @context
member, an
invalid remote context
has been detected and processing is aborted; otherwise,
set context to the value of that member.invalid local context
error has been detected and processing is aborted.@base
key and remote contexts is empty, i.e., the currently
being processed context is not a remote context:
@base
key.invalid base IRI
error has been detected and processing is aborted.@vocab
key:
@vocab
key.invalid vocab mapping
error has been detected and processing is aborted.@language
key:
@language
key.invalid default language
error has been detected and processing is aborted.@base
, @vocab
, or
@language
, invoke the
Create Term Definition algorithm,
passing result for This algorithm is called from the
Context Processing algorithm
to create a
After all dependencies for a
The algorithm has four required inputs which are:
an
cyclic IRI mapping
error has been detected and processing is aborted.keyword redefinition
error has been detected and processing is aborted.@id
-@id
and whose value is value.invalid term definition
error has been detected and processing is aborted.@type
:
@type
key, which must be a invalid type mapping
error has been detected and processing is aborted.@id
, nor @vocab
, nor an invalid type mapping
error has been detected and processing is aborted.@reverse
:
@id
, member, an
invalid reverse property
error has been detected and processing is aborted.@reverse
key
is not a invalid IRI mapping
error has been detected and processing is aborted.@reverse
key for value, :
), an
invalid IRI mapping
error has been detected and processing is aborted.@container
member,
set the @set
, nor
@index
, nor invalid reverse property
error has been detected (reverse properties only support set- and
index-containers) and processing is aborted.@id
and its value
does not equal term:
@id
key is not a invalid IRI mapping
error has been detected and processing is aborted.@id
key for
value, invalid IRI mapping
error has been detected and processing is aborted; if it equals @context
, an
invalid keyword alias
error has been detected and processing is aborted.:
):
invalid IRI mapping
error been detected and processing is aborted.@container
:
@container
key, which must be either
@list
, @set
, @index
,
or @language
. Otherwise, an
invalid container mapping
error
has been detected and processing is aborted.@language
and
does not contain the key @type
:
@language
key, which must be either invalid language mapping
error has been detected and processing is aborted.In JSON-LD documents, some keys and values may represent
In order to expand value to an
The algorithm takes two required and four optional input variables. The
required inputs are an false
and
:
), it is either
an :
)._
)
or suffix begins with double-forward-slash
(//
), return value as it is already an
This algorithm expands a JSON-LD document, such that all
Starting with its root element, we can process the
JSON-LD document recursively, until we have a fully
Finally, after ensuring result is in an
The algorithm takes three input variables: an
@graph
,
drop the free-floating @list
or its
@list
, the
expanded item must not be an list of lists
error has been detected and processing is aborted.@context
, set
@context
key as @context
, continue to
the next key.:
) nor it is a @reverse
, an
invalid reverse property map
error has been detected and processing is aborted.colliding keywords
error has been detected and processing is aborted.@id
and
value is not a invalid @id value
error has been detected and processing is aborted. Otherwise,
set expanded value to the result of using the
IRI Expansion algorithm,
passing @type
and value
is neither a invalid type value
error has been detected and processing is aborted. Otherwise,
set expanded value to the result of using the
IRI Expansion algorithm, passing
@graph
, set
expanded value to the result of using this algorithm
recursively passing @graph
for @value
and
value is not a invalid value object value
error has been detected and processing is aborted. Otherwise,
set expanded value to value. If expanded value
is @value
member of result to @type
member depends
on the existence of an @value
member.@language
and
value is not a invalid language-tagged string
error has been detected and processing is aborted. Otherwise,
set expanded value to lowercased value.@index
and
value is not a invalid @index value
error has been detected and processing is aborted. Otherwise,
set expanded value to value.@list
:
@graph
, continue with the next key
from element to remove the free-floating list.list of lists
error has been detected and processing is aborted.@set
, set
expanded value to the result of using this algorithm
recursively, passing @reverse
and
value is not a invalid @reverse value
error has been detected and processing is aborted. Otherwise
@reverse
as @reverse
member,
i.e., properties that are reversed twice, execute for each of its
property and item the following steps:
@reverse
:
@reverse
member, create
one and set its value to an empty @reverse
member in result
using the variable reverse map.@reverse
:
invalid reverse property value
has been detected and processing is aborted.@language
and
value is a invalid language map value
error has been detected and processing is aborted.@value
-item)
and (@language
-lowercased
language).@index
and
value is a @index
, add the key-value pair
(@index
-index) to
item.@list
and
expanded value is not already a @list
-expanded value.@reverse
member, create
one and initialize its value to an empty @reverse
member in result
using the variable reverse map.invalid reverse property value
has been detected and processing is aborted.@value
:
@value
, @language
, @type
,
and @index
. It must not contain both the
@language
key and the @type
key.
Otherwise, an
invalid value object
error has been detected and processing is aborted.@value
key is
@value
member
is not a @language
, an
invalid language-tagged value
error has been detected (only @type
member
and its value is not an invalid typed value
error has been detected and processing is aborted.@type
and its associated value is not an @set
or @list
:
@index
. Otherwise, an
invalid set or list object
error has been detected and processing is aborted.@set
, then
set result to the key's associated value.@language
, set result to @graph
,
drop free-floating values as follows:
@value
or @list
, set result to
@id
, set result to If, after the above algorithm is run, the result is a
@graph
key, set the
result to the value of @graph
's value. Otherwise, if the result
is
Some values in JSON-LD can be expressed in a
If @id
or @vocab
,
a @id
whose
value is the result of using the
IRI Expansion algorithm on value
is returned.
Otherwise, the result will be a @value
member whose value is the passed value.
Additionally, an @type
member will be included if there is a
@language
member if value is a
The algorithm takes three required inputs: an
@id
, return a new
@id
and the value is the result of using the
IRI Expansion algorithm, passing
@vocab
, return
a new @id
and the value is the result of
using the IRI Expansion algorithm, passing
@value
member whose value is set to
value.@type
member to
result and set its value to the value associated with the
@language
to result and set its
value to the language code associated with the
@language
to result and set its value to the
This algorithm compacts a JSON-LD document, such that the given
Starting with its root element, we can process the
JSON-LD document recursively, until we have a fully
@index
or @language
maps.The final output is a @context
key, if a non-empty @graph
key because result
contained two or more items in an
The algorithm takes five required input variables: an compactArrays
.
To begin, the compactArrays
is set to
1
), compactArrays
is @value
or @id
member and the result of using the
Value Compaction algorithm,
passing @reverse
,
otherwise to @id
or
@type
:
@type
,
@type
1
), then
set compacted value to its only item.@reverse
:
@reverse
for
@set
or
compactArrays
is @reverse
for iri,
and @index
and
@index
,
then the compacted result will be inside of an @index
container, drop the @index
property by continuing
to the next expanded property.@index
,
@value
, or @language
:
@list
, otherwise pass
the key's associated value for element.@list
:
@list
for iri, and compacted item
for value.@index
, then add a key-value pair
to compacted item where the key is the
result of the IRI Compaction algorithm,
passing @index
as iri, and the value associated with the
@index
key in expanded item as value.compaction to list of lists
error has been detected and processing is aborted.@language
or
@index
:
@language
and
compacted item contains the key
@value
, then set compacted item
to the value associated with its @value
key.compactArrays
is @set
or
@list
, or expanded property is
@list
or @graph
and
compacted item is not an If, after the algorithm outlined above is run, the result result
is an @graph
as iri and whose value is the @context
member to result and set its value
to the passed context.
When there is more than one
In order to make
To make use of an
To create an @none
. This allows the
Term Selection algorithm to fall back
to choosing more generic
The algorithm takes one required input: the
@none
. If the
@none
. If there
is a @language
and its value is a new empty
@type
and its value is a new empty @type
member in type/language map using the variable
type map.@reverse
member, create one and set its value to the @type
member in type/language map using the variable
type map.@language
member in type/language map using the variable
language map.@null
; otherwise set it
to the language code in @language
member in type/language map using the variable
language map.@none
member, create one and set its value to the @type
member in type/language map using the variable
type map.@none
member, create one and set its value to the This algorithm compacts an
If the passed
If no
This algorithm takes three required inputs and three optional inputs.
The required inputs are an false
.
@none
.@language
,
and type/language value to @null
. These two
variables will keep track of the preferred
@index
, then append the value @index
to containers.@type
, type/language value to
@reverse
, and append @set
to containers.@index
is a not key in value, then
append @list
to containers.@list
in value.@none
and
item type to @none
.@value
:
@language
,
then set item language to its associated
value.@type
, set item type to its
associated value.@null
.@id
.@value
, then set common language
to @none
because list items have conflicting
languages.@none
because list items have conflicting
types.@none
and
common type is @none
, then
stop processing items in the list because it has been
detected that there is no common language or type amongst
the items.@none
.@none
.@none
then set
type/language to @type
and
type/language value to common type.@language
and does not contain the key @index
,
then set type/language value to its associated
value and append @language
to
containers.@type
, then set type/language value to
its associated value and set type/language to
@type
.@type
and set type/language value to @id
.@set
to containers.@none
to containers. This represents
the non-existence of a @null
. This is the key under which @reverse
, append
@reverse
to preferred values.@id
or @reverse
and value has an @id
member:
@id
key in value for
iri, @id
key in value,
then append @vocab
, @id
, and
@none
, in that order, to preferred values.@id
, @vocab
, and
@none
, in that order, to preferred values.@none
, in
that order, to preferred values.:
),
then continue to the next :
), and the substring of iri
that follows after the value of the
This algorithm, invoked via the IRI Compaction algorithm,
makes use of an
The
This algorithm has five required inputs. They are:
an
The value to compact has either an @id
or an
@value
member.
For the former case, if the @id
or @vocab
and value consists of only an @id
member and, if
the @index
, an @index
member, value
can be compacted to a @id
member.
Otherwise, value cannot be compacted and is returned as is.
For the latter case, it might be possible to compact value
just into the value associated with the @value
member.
This can be done if the @index
member or the @index
. It can
also be done if @value
is the only member in value
(apart an @index
member in case the @index
) and
either its associated value is not a
This algorithm has four required inputs: an
@index
member and the
@index
, decrease number members by
1
.2
, return
value as it cannot be compacted.@id
member:
1
and
the @id
, return the result of using the
IRI compaction algorithm,
passing @id
member for iri.1
and
the @vocab
, return the result of using the
IRI compaction algorithm,
passing @id
member for iri, and
@type
member whose
value matches the @value
member
of value.@language
member whose
value matches the @value
member of value.1
and either
the value of the @value
member is not a @value
member.This algorithm flattens an expanded JSON-LD document by collecting all
properties of a
First, a node map is generated using the
Node Map Generation algorithm
which collects all properties of a
The algorithm takes two input variables, an element to flatten and
an optional context used to compact the flattened document. If not
passed, context is set to
This algorithm generates new 0
.
@default
and whose value is
an empty @default
member of node map, which is a @default
, perform the following steps:
@id
member whose value is set to graph name.@graph
member to entry and set it to an
empty @graph
member of entry,
unless the only member of node is @id
.@id
.@graph
keyword (or its alias)
at the top-level other than @context
, even if the context is empty or if there is only one element to
put in the @graph
This algorithm creates a @default
member, all other graphs are
stored under their
The algorithm recursively runs over an expanded JSON-LD document to
collect all @default
)
and whose associated values are @id
member. If a @id
member or it is identified by a @type
.
The algorithm takes as input an expanded JSON-LD document element and a reference to
a @default
), an
@type
member, perform for each
item the following steps:
@value
member, perform the following steps:
@list
member of list.@list
member, perform
the following steps:
@list
whose value is initialized to an empty @list
member for element, @id
member, set id
to its value and remove the member from element. If id
is a @id
whose
value is id.@id
whose value is id.@list
member of list.@type
key, append
each item of its associated @type
key of
node unless it is already in that @type
member from element.@index
member, set the @index
member of node to its value. If @index
member with a different value, a
conflicting indexes
error has been detected and processing is aborted. Otherwise, continue by
removing the @index
member from element.@reverse
member:
@id
whose
value is id.@reverse
member of
element.@reverse
member from element.@graph
member, recursively invoke this
algorithm passing the value of the @graph
member for element,
node map, and id for @graph
member from element.This algorithm is used to generate new
The simplest case is if there exists already a _:b
and the
counter. If the passed identifier is not
The algorithm takes a single input variable identifier which may
be 0
by default.
_:b
and counter.1
.This section describes algorithms to deserialize a JSON-LD document to an
Throughout this section, the following vocabulary
Prefix | IRI |
---|---|
rdf | http://www.w3.org/1999/02/22-rdf-syntax-ns# |
rdfs | http://www.w3.org/2000/01/rdf-schema# |
xsd | http://www.w3.org/2001/XMLSchema# |
This algorithm deserializes a JSON-LD document to an
The JSON-LD document is expanded and converted to a node map using the
Node Map Generation algorithm.
This allows each graph represented within the document to be
extracted and flattened, making it easier to process each
@id
member which corresponds to the
The algorithm takes a JSON-LD document element and returns an
This algorithm generates new 0
.
@type
, then for each
type in values, append a rdf:type
,
and type to triples.@list
key from
item and list triples. Append first a
@default
, add
triples to the This algorithm takes a
The algorithm takes as its sole argument item which must be
either a
@id
member is a @id
member.@value
member in item.
@type
member of item or true
or false
which is the
xsd:boolean
.xsd:double
, convert value to a
xsd:double
as defined in [[!XMLSCHEMA11-2]]
and described in
Data Round Tripping.
If datatype is xsd:double
.xsd:integer
, convert value to a
xsd:integer
as defined in [[!XMLSCHEMA11-2]]
and described in
Data Round Tripping.
If datatype is xsd:integer
.xsd:string
or rdf:langString
, depending on if
item has an @language
member.@language
member, add the value associated with the
@language
key as the language tag of literal.List Conversion is the process of taking a
For each element of the rdf:first
and
rdf:rest
rdf:nil
if the
rdf:first
triple is omitted.
The algorithm takes two inputs: an
rdf:nil
.rdf:first
, and object.rdf:nil
. Append a
rdf:rest
, and rest to list triples.rdf:nil
if bnodes is empty.This algorithm serializes an
Iterate through each graph in the dataset, converting each
xsd:integer
or xsd:double
are converted
to a xsd:boolean
are converted to rdf:type
flag is set to true, rdf:type
predicates will be serialized as @type
as long as the associated object is
either an
The algorithm takes one required and two optional inputs: an rdf:type
that both default to
@default
whose value references
default graph.@default
, otherwise to the
@id
whose value is name.@id
whose value is
set to subject.@id
whose value is
set to object.rdf:type
, the
use rdf:type
flag is not @type
member of node; unless such an item already exists.
If no such member exists, create one
and initialize it to an @id
member of node
to
the object member of node usages map, unless it already exists.usages
member, create one and initialize it to
an empty usages
member of the object
member of node map using the variable usages.node
, property
, and value
to the usages node
member
is set to a reference to node, property
to predicate,
and value
to a reference to value.rdf:nil
member, continue
with the next name-graph object pair as the graph does
not contain any lists that need to be converted.rdf:nil
member
of graph object.usages
member of
nil, perform the following steps:
node
member of usage, property to
the value of the property
member of usage,
and head to the value of the value
member
of usage.rdf:rest
,
the @id
member of node
has only one member,
the value associated to the usages
member of node has
exactly 1 entry,
node has a rdf:first
and rdf:rest
property,
both of which have as value an @type
member whose value is an array with a single item equal to
rdf:List
,
node represents a well-formed list node.
Perform the following steps to traverse the list backwards towards its head:
rdf:first
member of
node to the list @id
member of
node to the list nodes usages
member of node.node
member
of node usage, property to the value of the
property
member of node usage, and
head to the value of the value
member
of node usage.@id
member of node is an
rdf:first
, i.e., the
detected list is nested inside another list
@id
of node equals
rdf:nil
, i.e., the detected list is empty,
continue with the next usage item. The
rdf:nil
node cannot be converted to a
@id
member of head.rdf:rest
member of head.@id
member from head.@list
member to head and initialize
its value to the list @graph
member to node and initialize
its value to an empty @graph
member of node after
removing its usages
member, unless the only
remaining member of n is @id
.usages
member, unless the only remaining member of
node is @id
.This algorithm transforms an RDF literal to a JSON-LD
xsd:integer
or xsd:double
are converted
to a xsd:boolean
are converted to
This algorithm takes two required inputs: a value to be converted
to a
@id
whose value is set to
value.xsd:string
, set
converted value to the
xsd:boolean
, set
converted value to true
, or false
. If it matches neither,
set type to xsd:boolean
.xsd:integer
or
xsd:double
and its
xsd:integer
or xsd:double
according [[!XMLSCHEMA11-2]], set converted value
to the result of converting the
@language
to result and set its value to the
xsd:string
which is ignored.@value
to result whose value
is set to converted value.@type
to result whose value is set to type.When deserializing JSON-LD to RDF
JSON-native xsd:integer
or xsd:double
depending on whether the xsd:boolean
,
and xsd:string
.
The numeric or boolean values themselves are converted to
The xsd:integer
, is a finite-length sequence of decimal
digits (0-9
) with an optional leading minus sign; leading
zeros are prohibited. In JavaScript, implementers can use the following
snippet of code to convert an integer to
The xsd:double
, consists of a mantissa followed by the
character E
, followed by an exponent. The mantissa is a
decimal number and the exponent is an integer. Leading zeros and a
preceding plus sign (+
) are prohibited in the exponent.
If the exponent is zero, it is indicated by E0
. For the
mantissa, the preceding optional plus sign is prohibited and the
decimal point is required. Leading and trailing zeros are prohibited
subject to the following: number representations must be normalized
such that there is a single digit which is non-zero to the left of
the decimal point and at least a single digit to the right of the
decimal point unless the value being represented is zero. The
canonical representation for zero is 0.0E0
.
xsd:double
's value space is defined by the IEEE
double-precision 64-bit floating point type [[!IEEE-754-2008]] whereas
the value space of JSON
The true
and false
.
When JSON-native xsd:double
with a value
of 2.0
will, e.g., result in an xsd:integer
with a value of 2
in xsd:integer
to a
To ensure lossless round-tripping the
Serialize RDF as JSON-LD algorithm
specifies a use native types flag which controls whether
xsd:integer
, xsd:double
, or
xsd:boolean
are converted to their JSON-native
counterparts. If the use native types flag is set to
Some JSON serializers, such as PHP's native implementation in some versions,
backslash-escape the forward slash character. For example, the value
http://example.com/
would be serialized as http:\/\/example.com\/
.
This is problematic as other JSON parsers might not understand those escaping characters.
There is no need to backslash-escape forward slashes in JSON-LD. To aid
interoperability between JSON-LD processors, forward slashes MUST NOT be
backslash-escaped.
This API provides a clean mechanism that enables developers to convert JSON-LD data into a variety of output formats that are often easier to work with.
The JSON-LD API uses
The JsonLdProcessor interface is the high-level programming structure that developers use to access the JSON-LD transformation methods.
It is important to highlight that implementations do not modify the input parameters.
If an error is detected, the Promise is
rejected passing a JsonLdError with the corresponding error
code
and processing is stopped.
If the documentLoader
option is specified, it is used to dereference remote documents and contexts.
The documentUrl
in the returned RemoteDocument
is used as contextUrl
is used instead of looking at the HTTP Link Header directly. For the sake of simplicity, none of the algorithms
in this document mention this directly.
Compacts the given input using the context according to the steps in the Compaction algorithm:
application/json
,
nor application/ld+json
, nor any other media type using a
+json
suffix as defined in [[RFC6839]]
or if the document cannot be parsed as JSON, reject the promise passing an
loading document failed
error.base
option
overrides the expandContext
has been passed, update the expandContext
as expandContext
is a @context
member, pass that member's value instead.http://www.w3.org/ns/json-ld#context
link relation
and a content type of application/json
or any media type
with a +json
suffix as defined in [[RFC6839]] except
application/ld+json
, update the application/ld+json
If
multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context
link relation are found, the promise is rejected with a JsonLdError whose code is set to
multiple context link headers
and processing is terminated.@context
member, set
context to that member's value.compactArrays
flag in options.input
;
it can be specified by using a Expands the given input according to the steps in the Expansion algorithm:
application/json
,
nor application/ld+json
, nor any other media type using a
+json
suffix as defined in [[RFC6839]], reject the promise passing an
loading document failed
error.base
option
overrides the expandContext
has been passed, update the expandContext
as expandContext
is a @context
member, pass that member's value instead.http://www.w3.org/ns/json-ld#context
link relation
and a content type of application/json
or any media type
with a +json
suffix as defined in [[RFC6839]] except
application/ld+json
, update the application/ld+json
If
multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context
link relation are found, the promise is rejected with a JsonLdError whose code is set to
multiple context link headers
and processing is terminated.Flattens the given input and compacts it using the passed context according to the steps in the Flattening algorithm:
application/json
,
nor application/ld+json
, nor any other media type using a
+json
suffix as defined in [[RFC6839]], reject the promise passing an
loading document failed
error.base
option
overrides the expandContext
has been passed, update the expandContext
as expandContext
is a @context
member, pass that member's value instead.http://www.w3.org/ns/json-ld#context
link relation
and a content type of application/json
or any media type
with a +json
suffix as defined in [[RFC6839]] except
application/ld+json
, update the application/ld+json
If
multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context
link relation are found, the promise is rejected with a JsonLdError whose code is set to
multiple context link headers
and processing is terminated.@context
member, set
context to that member's value.0
)
to be used by the
Generate Blank Node Identifier algorithm.compactArrays
flag in options (which is internally passed to the
Compaction algorithm).input
;
it can be specified by using a The JsonLdContext type is used to refer to a value that
that may be a
The JsonLdOptions type is used to pass various options to the JsonLdProcessor methods.
true
, the JSON-LD processor replaces arrays with just
one element with that element during compaction. If set to false
,
all arrays will remain arrays even if they have just one element.
json-ld-1.0
, the implementation has to produce
exactly the same results as the algorithms defined in this specification.
If set to another value, the JSON-LD processor is allowed to extend
or modify the algorithms defined in this specification to enable
application-specific optimizations. The definition of such
optimizations is beyond the scope of this specification and thus
not defined. Consequently, different implementations may implement
different optimizations. Developers must not define modes beginning
with json-ld
as they are reserved for future versions
of this specification.Users of an API implementation can utilize a callback to control how remote documents and contexts are retrieved. This section details the parameters of that callback and the data structure used to return the retrieved context.
The LoadDocumentCallback defines a callback that custom document loaders have to implement to be used to retrieve remote documents and contexts.
All errors result in the loading document failed
or multiple context link headers
as described in the next section.
The RemoteDocument type is used by a LoadDocumentCallback to return information about a remote document or context.
http://www.w3.org/ns/json-ld#context
link relation in the
response. If the response's content type is application/ld+json
,
the HTTP Link Header is ignored. If multiple HTTP Link Headers using
the http://www.w3.org/ns/json-ld#context
link relation are found,
the multiple context link headers
.This section describes the datatype definitions used within the JSON-LD API for error handling.
The JsonLdError type is used to report processing errors.
The JsonLdErrorCode represents the collection of valid JSON-LD error codes.
@index
member was encountered whose value was
not a @id
member was encountered whose value was not a
http://www.w3.org/ns/json-ld#context
link relation
have been detected.@type
member in a @language
member in a @container
member was encountered whose value was
not one of the following @list
, @set
, or @index
.@type
member has been detected,
i.e., the value was neither a @value
member of a
@context
are allowed in reverse property maps.@reverse
member has been detected,
i.e., the value was not a A large amount of thanks goes out to the JSON-LD Community Group participants who worked through many of the technical issues on the mailing list and the weekly telecons - of special mention are Niklas Lindström, François Daoust, Lin Clark, and Zdenko 'Denny' Vrandečić. The editors would like to thank Mark Birbeck, who provided a great deal of the initial push behind the JSON-LD work via his work on RDFj. The work of Dave Lehn and Mike Johnson are appreciated for reviewing, and performing several implementations of the specification. Ian Davis is thanked for his work on RDF/JSON. Thanks also to Nathan Rixham, Bradley P. Allen, Kingsley Idehen, Glenn McDonald, Alexandre Passant, Danny Ayers, Ted Thibodeau Jr., Olivier Grisel, Josh Mandel, Eric Prud'hommeaux, David Wood, Guus Schreiber, Pat Hayes, Sandro Hawke, and Richard Cyganiak for their input on the specification.