This document is also available in this non-normative format: diff to previous version
Copyright
©
2010-2012
2010-2013
W3C
®
(
MIT
,
ERCIM
,
Keio
,
Beihang
),
All
Rights
Reserved.
W3C
liability
,
trademark
and
document
use
rules
apply.
JSON
[
RFC4627
]
has
proven
to
be
a
highly
useful
object
serialization
and
messaging
format.
JSON-LD
[
JSON-LD
]
harmonizes
the
representation
of
Linked
Data
in
JSON
by
outlining
a
common
JSON
representation
format
for
expressing
directed
graphs;
mixing
both
Linked
Data
and
non-Linked
Data
in
a
single
document.
This
document
outlines
specification
defines
an
Application
Programming
Interface
(API)
and
a
set
of
algorithms
for
programmatically
transforming
programmatic
transformations
of
JSON-LD
documents
in
order
to
make
them
easier
to
work
with
in
programming
environments
like
JavaScript,
Python,
and
Ruby.
documents.
Restructuring
data
according
the
defined
transformations
often
dramatically
simplifies
its
usage.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This
document
has
been
under
development
for
over
18
25
months
in
the
JSON
for
Linking
Data
Community
Group.
The
document
has
recently
been
transferred
to
the
RDF
Working
Group
for
review,
improvement,
and
publication
along
the
Recommendation
track.
While
this
is
a
First
Public
Working
Draft
publication,
the
The
specification
has
undergone
significant
development,
review,
and
changes
during
the
course
of
the
last
18
months
and
is
more
mature
than
the
First
Public
Working
Draft
status
implies.
25
months.
There
are
currently
several
independent
five
interoperable
implementations
of
this
specification.
There
is
specification
and
a
fairly
complete
test
suite
and
a
live
JSON-LD
editor
that
is
capable
of
demonstrating
the
features
described
in
this
document.
While
development
on
implementations,
the
test
suite
and
the
live
editor
will
continue,
they
are
believed
to
be
mature
enough
to
be
integrated
into
a
non-production
system
at
this
point
in
time
with
the
expectation
that
they
could
be
used
in
a
production
system
within
the
next
year.
Issue
1
[
JSON-LD-TESTS
It
is
important
for
readers
to
understand
that
the
scope
of
this
document
is
currently
under
debate
and
new
features
may
be
added
to
the
specification.
Existing
features
may
be
modified
heavily
or
removed
entirely
from
the
specification
upon
further
review
and
feedback
from
the
broader
community.
This
is
a
work
in
progress
and
publication
as
a
First
Public
Working
Draft
does
not
require
that
all
Working
Group
members
agree
on
the
content
of
the
document.
].
This
document
was
published
by
the
RDF
Working
Group
as
a
First
Public
Last
Call
Working
Draft.
This
document
is
intended
to
become
a
W3C
Recommendation.
If
you
wish
to
make
comments
regarding
this
document,
please
send
them
to
public-rdf-comments@w3.org
(
subscribe
,
archives
).
The
Last
Call
period
ends
11
May
2013.
All
feedback
is
comments
are
welcome.
The Working Group welcomes reports of implementations, sent to the comments address. If we gather sufficient evidence of interoperable implementations, the group may request to skip Call for Implementations (Candidate Recommendation) drafts and have the next round of publications be Proposed Recommendations.
Publication as a Last Call Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This is a Last Call Working Draft and thus the Working Group has determined that this document has satisfied the relevant technical requirements and is sufficiently stable to advance through the Technical Recommendation process.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy .
JsonLdProcessor
This section is non-normative.
This
document
is
a
detailed
specification
for
an
Application
Programming
Interface
for
the
JSON-LD
Syntax.
syntax.
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
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
[
RDF-CONCEPTS
RDF11-CONCEPTS
].
This section is non-normative.
The
JSON-LD
Syntax
specification
[
JSON-LD
]
outlines
defines
a
language
that
may
be
used
syntax
to
express
Linked
Data
in
JSON.
Often,
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
processed
consumed
by
specific
applications.
JSON-LD
uses
contexts
to
allow
Linked
Data
to
be
expressed
in
a
programming
environment
like
JavaScript,
Python
way
that
is
specifically
tailored
to
a
particular
person
or
Ruby.
application.
By
providing
a
context
,
JSON
data
can
be
expressed
in
a
way
that
is
a
natural
fit
for
a
particular
person
or
application
whilst
also
indicating
how
the
data
should
be
understood
at
a
global
scale.
In
order
for
people
or
applications
to
share
data
that
was
created
using
a
context
that
is
different
from
their
own,
a
JSON-LD
processor
must
be
able
to
transform
a
document
from
one
context
to
another.
Instead
of
requiring
JSON-LD
processors
to
write
specific
code
for
every
imaginable
context
switching
scenario,
it
is
much
easier
to
specify
a
single
algorithm
that
can
remove
any
context
.
Similarly,
another
algorithm
can
be
specified
to
subsequently
apply
any
context
.
These
two
algorithms
represent
the
most
basic
transformations
of
JSON-LD
documents.
They
are
referred
to
as
expansion
and
compaction
,
respectively.
There
are
three
four
major
types
of
transformation
that
are
discussed
in
this
document;
compaction,
document:
expansion,
compaction,
flattening,
and
RDF
conversion.
Software
algorithms
are
easiest
to
write
when
the
data
This
section
is
non-normative.
The
algorithm
that
they
are
processing
have
removes
context
is
called
expansion
.
Before
performing
any
other
transformations
on
a
regular
form.
Since
information
can
be
represented
by
JSON-LD
in
a
variety
of
different
ways,
transforming
all
document,
it
is
easiest
to
remove
any
context
from
it
and
to
make
data
structures
more
regular.
To
get
an
idea
of
these
methods
into
a
uniform
structure
allows
how
context
and
data
structuring
affects
the
developer
to
simplify
their
processing
code.
For
example,
note
same
data,
here
is
an
example
of
JSON-LD
that
the
following
input
uses
only
term
terms
s
and
is
fairly
compact:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "homepage": { "@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id" } }, "@id": "http://me.markus-lanthaler.com/", "name": "Markus Lanthaler", "homepage": "http://www.markus-lanthaler.com/" }
The
next
input
example
uses
one
IRI
to
express
a
property,
property
and
an
array
to
encapsulate
another,
but
leaves
the
rest
of
the
information
untouched.
{ "@context": { "website": "http://xmlns.com/foaf/0.1/homepage" }, "@id": "http://me.markus-lanthaler.com/", "http://xmlns.com/foaf/0.1/name": "Markus Lanthaler", "website": { "@id": "http://www.markus-lanthaler.com/" } }
While
Note
that
both
inputs
are
valid
JSON-LD,
writing
a
program
to
handle
every
permutation
of
possible
inputs
can
be
difficult,
especially
when
JSON-LD
and
both
represent
the
incoming
same
information.
The
difference
is
in
their
context
could
change
as
well.
To
information
and
in
the
data
structures
used.
A
JSON-LD
processor
can
remove
context
and
ensure
that
the
data
can
be
given
a
is
more
uniform
structure,
JSON-LD
introduces
the
notion
of
expansion.
regular
by
employing
expansion
.
Expansion
performs
has
two
important
operations.
The
first
is
to
expand
goals:
removing
any
contextual
information
from
the
document,
and
ensuring
all
values
that
are
IRI
s
to
their
fully
expanded
represented
in
a
regular
form.
The
second
is
These
goals
are
accomplished
by
expanding
all
properties
to
express
absolute
IRIs
and
by
expressing
all
values
in
arrays
in
expanded
form
.
To
transform
both
inputs
above
to
.
Expanded
form
is
the
same
representation,
most
verbose
and
regular
way
of
expressing
of
values
in
JSON-LD;
all
contextual
information
from
the
developer
could
do
document
is
instead
stored
locally
with
each
value.
Running
the
following:
function expansionCallback(output) {
console.log(output);
}
Expansion
algorithm
(
operation)
against
the
above
// the second parameter is 'null' because the developer does not wish to
// inject another context value
jsonld.expand(input1, null, expansionCallback);
jsonld.expand(input2,
null,
expansionCallback);
expand
The
output
for
both
calls
will
be:
examples
results
in
the
following
output:
[ { "@id": "http://me.markus-lanthaler.com/", "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ], "http://xmlns.com/foaf/0.1/homepage": [ { "@id": "http://www.markus-lanthaler.com/" } ] } ]
Note
that
in
the
example
above;
output
above
all
context
definitions
have
been
removed,
all
term
terms
and
prefixes
compact
IRIs
have
been
expanded
to
full
IRIs,
absolute
IRIs
,
and
all
literal
JSON-LD
values
s
are
expressed
in
arrays
in
expanded
form
.
While
the
output
is
more
verbose
and
difficult
for
a
human
to
read,
it
is
easier
for
establishes
a
software
program
to
process
baseline
that
makes
JSON-LD
processing
easier
because
of
its
very
regular
structure.
This section is non-normative.
While
expansion
expands
removes
context
from
a
given
input
as
much
as
possible,
compaction
performs
input,
compaction's
primary
function
is
to
perform
the
opposite
operation
-
expressing
operation:
to
express
a
given
input
as
succinctly
as
possible.
While
expansion
is
meant
according
to
produce
something
a
particular
context
.
Compaction
applies
a
context
that
specifically
tailors
the
way
information
is
easy
to
process
by
software
programs,
compaction
is
meant
to
produce
something
expressed
for
a
particular
person
or
application.
This
simplifies
applications
that
is
easy
consume
JSON
or
JSON-LD
by
expressing
the
data
in
application-specific
terms,
and
it
makes
the
data
easier
to
ready
read
by
software
developers.
humans.
Compaction
uses
a
developer-supplied
context
to
compresses
all
shorten
IRI
IRIs
s
to
term
terms
s
or
prefix
compact
IRIs
es,
and
compacts
all
literal
JSON-LD
values
s
expressed
in
expanded
form
to
simple
values
such
as
much
as
possible.
strings
or
numbers
.
The
For
example,
assume
the
following
example
expresses
expanded
JSON-LD
input
that
has
already
been
fully
expanded:
document:
[ { "@id": "http://me.markus-lanthaler.com/", "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ], "http://xmlns.com/foaf/0.1/homepage": [ { "@id": "http://www.markus-lanthaler.com/" } ] } ]
A
developer
that
wants
to
transform
the
data
above
into
a
more
human-readable
form,
could
do
Additionally,
assume
the
following
using
the
developer-supplied
JSON-LD
API:
context
:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "homepage": { "@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id" } } }jsonld.compact(expandedInput, "http://json-ld.org/contexts/person.jsonld", compactionCallback);
The
following
would
be
Running
the
Compaction
Algorithm
(
compact
operation)
given
the
context
supplied
above
against
the
JSON-LD
input
document
provided
above
would
result
of
in
the
call
above:
following
output:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "homepage": { "@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id" } }, "@id": "http://me.markus-lanthaler.com/", "name": "Markus Lanthaler", "homepage": "http://www.markus-lanthaler.com/" }
Note
that
all
of
the
term
IRIs
s
have
been
compressed
and
compacted
to
terms
as
specified
in
the
context
,
which
has
been
injected
into
the
output.
While
compacted
output
is
most
useful
to
humans,
it
can
is
also
be
carefully
used
to
generate
structures
that
are
easy
to
use
for
program
against.
Compaction
enables
developers
to
program
against
as
well.
map
any
expanded
document
into
an
application-specific
compacted
document.
While
the
context
provided
above
mapped
http://xmlns.com/foaf/0.1/name
to
name
,
it
could
also
have
been
mapped
to
any
other
term
provided
by
the
developer.
This section is non-normative.
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
node
may
be
spread
across
a
number
of
different
JSON
objects
.
By
flattening
a
document,
all
properties
of
a
node
are
collected
in
a
single
JSON
object
and
from
all
blank
nodes
are
labeled
with
a
blank
node
identifier
.
This
may
drastically
simplify
the
code
required
to
process
JSON-LD
data
in
certain
applications.
For example, assume the following JSON-LD input document:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "knows": "http://xmlns.com/foaf/0.1/knows" }, "@id": "http://me.markus-lanthaler.com/", "name": "Markus Lanthaler", "knows": [ { "name": "Dave Longley" } ] }
Running
the
Flattening
algorithm
(
flatten
operation)
with
a
context
set
to
null
to
prevent
compaction
returns
the
following
document:
[ { "@id": "_:t0", "http://xmlns.com/foaf/0.1/name": [ { "@value": "Dave Longley" } ] }, { "@id": "http://me.markus-lanthaler.com/", "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ], "http://xmlns.com/foaf/0.1/knows": [ { "@id": "_:t0" } ] } ]
Note
how
in
the
output
above
all
properties
of
a
node
are
collected
in
a
single
JSON
object
and
how
the
blank
node
representing
"Dave
Longley"
has
been
assigned
the
blank
node
identifier
_: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:
{ "@context": { "name": "http://xmlns.com/foaf/0.1/name", "knows": "http://xmlns.com/foaf/0.1/knows" }, "@graph": [ { "@id": "_:t0", "name": "Dave Longley" }, { "@id": "http://me.markus-lanthaler.com/", "name": "Markus Lanthaler", "knows": { "@id": "_:t0" } } ] }
Please
note
that
the
result
of
flattening
and
compacting
a
document
is
always
a
JSON
object
which
contains
an
@graph
member
that
represents
the
default
graph
.
This section is non-normative.
JSON-LD
can
be
used
to
losslessly
express
the
RDF
serialize
data
model
expressed
in
RDF
as
described
in
the
RDF
Concepts
document
[
RDF-CONCEPTS
RDF11-CONCEPTS
].
This
ensures
that
data
can
be
round-tripped
to
and
from
any
RDF
syntax,
like
N-Triples
or
TURTLE,
syntax
without
any
loss
in
the
fidelity
of
the
data.
Assume
fidelity.
For
example,
assume
the
following
RDF
input
serialized
in
N-Triples
format:
Turtle
[
TURTLE
]:
<http://me.markus-lanthaler.com/> <http://xmlns.com/foaf/0.1/name> "Markus Lanthaler" . <http://me.markus-lanthaler.com/> <http://xmlns.com/foaf/0.1/homepage><http://manu.sporny.org/> .";<http://www.markus-lanthaler.com/> .
A
developer
can
use
Using
the
JSON-LD
API
to
Convert
from
RDF
algorithm
a
developer
could
transform
the
markup
above
this
document
into
a
JSON-LD
document:
function conversionCallback(result)
{
console.log("JSON-LD Document: ", result);
};
jsonld.fromRDF(data,
conversionCallback,
{"format":
"ntriples"});
The
following
expanded
output
would
be
the
result
of
the
call
above:
JSON-LD:
[ { "@id": "http://me.markus-lanthaler.com/", "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ], "http://xmlns.com/foaf/0.1/homepage": [ { "@id": "http://www.markus-lanthaler.com/" } ] } ]
Note
that
the
output
above,
above
could
easily
be
compacted
to
produce
the
following
using
the
technique
outlined
in
the
previous
section:
{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://manu.sporny.org/about/#manu",
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
Transforming
section.
It
is
also
possible
to
transform
the
object
above
JSON-LD
document
back
to
RDF
is
as
simple
as
calling
using
the
toRDF()
method:
Convert
to
RDF
algorithm
.
All
examples
and
Normalization
Issue
2
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
currently
two
other
API
methods
three
classes
of
products
that
are
in
active
development
and
were
not
ready
for
publication
at
the
time
this
document
was
published.
Framing
allows
a
developer
can
claim
conformance
to
force
a
different
layout
for
the
data
this
specification:
JSON-LD
Processors
,
JSON-LD
API
Implementations
,
and
effectively
perform
query-by-example
on
JSON-LD-RDF
Converters
.
A
conforming
JSON-LD
documents
-
this
Processor
is
most
useful
when
a
JSON-LD-based
REST
API
does
not
know
the
exact
form
of
system
which
can
perform
the
data
it
is
getting
in,
but
still
wants
to
operate
upon
it
if
some
bare
essentials
are
found
Expansion
,
Compaction
,
and
Flattening
operations
defined
in
the
data.
this
specification.
A
conforming
JSON-LD
normalization
allows
API
Implementation
is
a
conforming
JSON-LD
documents
to
be
deterministically
serialized
such
Processor
that
they
can
be
digitally
signed
or
be
used
to
find
exposes
the
differences
between
two
linked
data
graph
Application
Programming
Interface
(API)
s.
defined
in
this
specification.
It
is
expected
that
framing
will
be
a
part
of
MUST
implement
the
final
API.
It
is
expected
that
normalization
will
be
an
optional
feature
that
JSON-LD
processors
may
implement.
json-ld-1.0
processing
mode
(for
further
details,
see
the
processingMode
option
of
3.
The
Application
Programming
Interface
JsonLdOptions
).
This
JSON-LD
Processors
and
API
provides
a
clean
mechanism
that
enables
developers
Implementations
MUST
NOT
attempt
to
convert
JSON-LD
data
into
a
correct
malformed
IRIs
or
language
tags;
however,
they
MAY
issue
validation
warnings.
IRIs
are
not
modified
other
than
converted
between
relative
and
absolute
IRIs
.
A
conforming
JSON-LD-RDF
Converter
is
a
variety
of
output
formats
system
that
are
easier
can
perform
Conversion
to
work
with
RDF
and
Conversion
from
RDF
.
The
algorithms
in
various
programming
languages.
If
a
this
specification
are
generally
written
with
more
concern
for
clarity
than
efficiency.
Thus,
JSON-LD
Processors
and
API
is
provided
Implementations
may
implement
the
algorithms
given
in
a
programming
environment,
this
specification
in
any
way
desired,
so
long
as
the
entirety
of
end
result
is
indistinguishable
from
the
following
API
must
result
that
would
be
implemented.
obtained
by
the
specification's
algorithms.
The
intent
of
the
Working
Group
and
the
Editors
Implementers
can
partially
check
their
level
of
this
specification
is
conformance
to
eventually
align
terminology
used
in
this
document
with
specification
by
successfully
passing
the
terminology
used
in
test
cases
of
the
RDF
Concepts
document
to
JSON-LD
test
suite
[
JSON-LD-TESTS
].
Note,
however,
that
passing
all
the
extent
to
which
it
makes
sense
to
do
so.
In
general,
if
there
is
an
analogue
to
terminology
used
in
this
document
tests
in
the
RDF
Concepts
document,
the
preference
is
test
suite
does
not
imply
complete
conformance
to
use
this
specification.
It
only
implies
that
the
terminology
in
implementation
conforms
to
aspects
tested
by
the
RDF
Concepts
document.
test
suite.
The
This
document
uses
the
following
is
an
explanation
of
terms
as
defined
in
JSON
[
RFC4627
].
Refer
to
the
general
terminology
used
JSON
Grammar
section
in
this
document:
[
RFC4627
]
for
formal
definitions.
@context
where
the
value,
or
the
@id
of
the
value,
is
null
explicitly
decouples
a
term's
association
with
an
IRI
.
A
key-value
pair
in
the
body
of
a
JSON-LD
document
@value
,
@list
,
or
@set
is
set
to
null
in
expanded
form,
then
the
entire
JSON
object
is
ignored.
Furthermore,
the
active
context
following
terminology
is
reset
and
when
used
within
a
context
,
it
removes
any
definition
associated
with
the
key,
unless
otherwise
specified.
throughout
this
document:
BlankNode
values
will
often
be
generated
differently
by
different
processors.
Note
Implementers
must
ensure
that
_:
.
@context
keyword
.
@value
,
@list
,
or
@set
keywords,
or
@context
@graph
@context
.
@value
member.
@list
member.
@set
member.
Processing
of
When
processing
a
JSON-LD
data
structure
is
managed
recursively.
During
processing,
structure,
each
processing
rule
is
applied
using
information
provided
by
the
active
context
.
Processing
begins
by
pushing
a
new
processor
state
This
section
describes
how
to
produce
an
active
context
.
The
active
context
onto
contains
the
processor
state
active
term
definitions
which
specify
how
properties
and
values
have
to
be
interpreted
as
well
as
the
current
base
IRI
,
the
vocabulary
mapping
and
the
default
language
.
Each
term
definition
stack
consists
of
an
IRI
mapping
,
a
boolean
flag
reverse
property
,
an
optional
type
mapping
or
language
mapping
,
and
initializing
an
optional
container
mapping
.
A
term
definition
can
not
only
be
used
to
map
a
term
to
an
IRI
,
but
also
to
map
a
term
to
a
keyword
,
in
which
case
it
is
referred
to
as
a
keyword
alias
.
When
processing,
the
active
context
with
the
initial
context
is
initialized
without
any
term
definitions
,
vocabulary
mapping
,
or
default
language
.
If
a
local
context
is
encountered,
encountered
during
processing,
a
new
active
context
is
created
by
cloning
the
existing
active
context
.
Then
the
information
from
the
local
context
is
merged
into
the
new
active
context
.
Given
that
local
contexts
may
contain
references
to
remote
contexts,
this
includes
their
retrieval.
The
This
section
is
non-normative.
First
we
prepare
a
new
active
context
is
used
for
expanding
properties
and
values
result
by
cloning
the
current
active
context
.
Then
we
normalize
the
form
of
the
passed
local
context
to
an
array
.
Local
contexts
may
be
in
the
form
of
a
JSON
object
(or
elements
of
,
a
string
,
or
an
array)
using
array
containing
a
term
mapping
.
It
combination
of
the
two.
Finally
we
process
each
context
contained
in
the
local
context
array
as
follows.
If
context
is
also
used
to
maintain
coercion
mapping
s
from
terms
to
datatypes,
language
mapping
s
from
terms
a
string
,
it
represents
a
reference
to
language
codes,
and
list
mapping
s
a
remote
context.
We
dereference
the
remote
context
and
set
mapping
s
for
terms.
Processors
must
use
replace
context
with
the
lexical
form
value
of
the
property
when
creating
a
mapping,
as
lookup
@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
context
by
recursively
using
this
algorithm
ensuring
that
there
is
performed
on
lexical
forms,
not
expanded
IRI
representations.
no
cyclical
reference.
A
local
If
context
is
identified
within
a
JSON
object
,
we
first
update
the
base
IRI
,
the
vocabulary
mapping
,
and
the
default
language
having
a
by
processing
three
specific
keywords:
,@context
property
with
a
string
@base
@vocab
,
and
@language
.
These
are
handled
before
any
other
keys
in
the
local
context
because
they
affect
how
the
other
keys
are
processed.
Then,
for
every
other
key
in
local
context
,
array
we
update
the
term
definition
or
a
JSON
object
in
result
.
Since
term
definitions
value.
When
processing
in
a
local
context
may
themselves
contain
terms
or
compact
IRIs
,
special
processing
rules
apply:
we
may
need
to
recurse.
When
doing
so,
we
must
ensure
that
there
is
no
cyclical
dependency,
which
is
an
error.
After
we
have
processed
any
term
definition
dependencies,
we
update
the
current
term
definition
,
which
may
be
a
keyword
alias
.
Finally, we return result as the new active context .
This
algorithm
specifies
how
a
new,
empty
new
active
context
is
updated
with
a
local
context
.
Let
context
be
the
value
of
@context
If
The
algorithm
takes
three
input
variables:
an
active
context
equals
null
,
reset
the
active
a
local
context
,
and
an
array
remote
contexts
which
is
used
to
detect
cyclical
context
inclusions.
If
remote
contexts
is
not
passed,
it
is
initialized
to
an
empty
array
.
recursive
context
inclusion
error
has
been
detected
and
processing
is
aborted;
otherwise,
add
context
to
remote
contexts
.
@context
JSON-POINTER
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.
@language
@base
Note:
This
feature
is
"at
risk"
or
null
and
may
be
removed
from
this
specification
based
on
feedback.
Please
send
feedback
to
public-rdf-comments@w3.org
.
Add
For
the
language
to
current
status
see
features
"at
risk"
in
JSON-LD
1.0
Support
for
the
local
context
.
Otherwise,
@base
keyword
might
be
removed
from
JSON-LD
1.0
if
implementation
experience
reveals
that
the
fact
that
a
document
may
have
multiple
base
IRIs
is
confusing
for
each
property
in
context
perform
developers.
It
is
also
being
discussed
whether
relative
IRIs
are
allowed
as
values
of
@base
or
whether
the
following
steps:
empty
string
should
be
used
to
explicitly
specify
that
there
isn't
a
base
IRI
,
which
could
be
used
to
ensure
that
relative
IRIs
remain
relative
when
expanding.
@base
key.
invalid
base
IRI
Expansion
on
error
has
been
detected
and
processing
is
aborted.
@vocab
key:
@vocab
key.
invalid
vocab
mapping
,
unless
the
property
error
has
been
detected
and
processing
is
@language
key:
@language
key.
invalid
default
language
error
has
been
detected
and
@id
@base
,
@language
@vocab
,
or
@type
properties,
throw
an
exception.
Issue
5
@language
,
invoke
the
Create
Term
Definition
algorithm
,
passing
result
for
active
context
,
context
for
local
context
,
key
,
and
defined
.
This
algorithm
is
called
from
the
property
has
Context
Processing
algorithm
to
create
a
term
definition
in
the
form
of
active
context
for
a
term
,
its
value
must
have
an
@id
property
with
being
processed
in
a
string
value
which
must
local
context
.
This
section
is
non-normative.
have
Term
definitions
are
created
by
parsing
the
form
of
a
information
in
the
given
local
context
for
the
given
term
,
.
If
the
given
term
is
a
compact
IRI
,
or
absolute
IRI
it
may
omit
an
.
Determine
the
IRI
mapping
by
performing
IRI
Expansion
depending
on
its
prefix
having
its
own
term
definition
.
If
the
prefix
is
a
key
in
the
local
context
,
then
its
term
definition
must
first
be
created,
through
recursion,
before
continuing.
Because
a
term
definition
can
depend
on
other
term
definitions
,
a
mechanism
must
be
used
to
detect
cyclical
dependencies.
The
solution
employed
here
uses
a
map,
defined
,
that
keeps
track
of
whether
or
not
a
term
has
been
defined
or
is
currently
in
the
associated
value.
If
process
of
being
defined.
This
map
is
checked
before
any
recursion
is
attempted.
After
all
dependencies
for
a
term
have
been
defined,
the
result
rest
of
the
IRI
mapping
information
in
the
local
context
for
the
given
term
is
an
absolute
taken
into
account,
creating
the
appropriate
IRI
mapping
,
merge
the
property
into
container
mapping
,
and
type
mapping
or
language
mapping
for
the
term
.
The
algorithm
has
four
required
inputs
which
are:
an
active
context
,
a
local
context
,
a
term
mapping
.
,
and
a
map
defined
.
cyclic
IRI
mapping
error
has
been
detected
and
processing
is
aborted.
,
keyword
redefinition
error
has
been
detected
and
processing
is
aborted.
@id
@context
,
an
invalid
keyword
alias
error
has
been
detected
and
processing
is
aborted.
invalid
term
definition
error
has
been
detected
and
processing
is
aborted.
@reverse
:
@id
,
an
@type
,
or
an
@language
,
member,
an
invalid
reverse
property
@reverse
key
is
not
a
,
absolute
invalid
IRI
,
or
the
keyword
mapping
@id
.
Determine
error
has
been
detected
and
processing
is
aborted.
@reverse
key
for
value
,
true
for
vocab
,
true
for
document
relative
,
local
context
,
and
defined
.
If
the
result
:
),
an
invalid
IRI
mapping
or
@id
,
merge
into
error
has
been
detected
and
processing
is
aborted.
@id
.
@container
@list
@index
@container
member;
otherwise
an
invalid
reverse
property
or
set
mapping
error
has
been
detected
(reverse
properties
only
support
index-containers)
and
processing
is
aborted.
@type
property,
@id
:
@language
@id
invalid
IRI
mapping
or
null
.
Merge
error
has
been
detected
and
processing
is
aborted.
@id
key
for
value
,
true
for
vocab
,
true
for
document
relative
,
local
context
,
and
defined
.
:
):
invalid
IRI
mapping
error
been
detected
and
processing
is
aborted.
@type
:
@type
key,
which
must
be
a
string
.
Otherwise,
an
invalid
type
mapping
until
no
changes
are
made,
mappings
error
has
been
detected
and
processing
is
aborted.
@id
,
nor
@vocab
,
nor
an
invalid
type
mapping
error
has
been
detected
and
processing
is
aborted.
@container
:
@container
key,
which
must
be
either
@list
,
@set
,
@index
,
or
@language
.
Otherwise,
an
Issue
6
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
null
or
a
string
.
Otherwise,
an
invalid
language
mapping
Issue
43
error
has
been
detected
and
processing
is
aborted.
Keys
and
In
JSON-LD
documents,
some
keys
and
values
are
evaluated
to
produce
an
may
represent
IRI
IRIs
.
This
section
defines
an
algorithm
for
transforming
a
value
representing
string
that
represents
an
IRI
into
an
actual
absolute
IRI
.
or
blank
node
identifier
.
It
also
covers
transforming
keyword
aliases
into
keywords
.
IRI
s
expansion
may
occur
during
context
processing
or
during
any
of
the
other
JSON-LD
algorithms.
If
IRI
expansion
occurs
during
context
processing,
then
the
local
context
and
its
related
defined
map
from
the
Context
Processing
algorithm
are
passed
to
this
algorithm.
This
allows
for
term
definition
dependencies
to
be
represented
as
processed
via
the
Create
Term
Definition
algorithm
.
This section is non-normative.
In
order
to
expand
value
to
an
absolute
IRI
,
we
must
first
determine
if
it
is
null
,
a
term
or
,
a
compact
keyword
alias
,
or
some
form
of
IRI
.
An
Based
on
what
we
find,
we
handle
the
specific
kind
of
expansion;
for
example,
we
expand
a
keyword
alias
to
a
keyword
and
a
term
to
an
absolute
IRI
according
to
its
IRI
mapping
in
the
active
context
.
While
inspecting
value
we
may
also
find
that
we
need
to
create
term
definition
dependencies
because
we're
running
this
algorithm
during
context
processing.
We
can
tell
whether
or
not
we're
running
during
context
processing
by
checking
local
context
against
null
.
We
know
we
need
to
create
a
term
definition
in
the
active
context
when
value
is
defined
a
key
in
[
RFC3987
the
local
context
]
containing
and
the
defined
map
does
not
have
a
scheme
along
key
for
value
with
path
an
associated
value
of
true
.
The
defined
map
is
used
during
Context
Processing
to
keep
track
of
which
terms
have
already
been
defined
or
are
in
the
process
of
being
defined.
We
create
a
term
definition
by
using
the
Create
Term
Definition
algorithm
.
The
algorithm
takes
two
required
and
four
optional
input
variables.
The
required
inputs
are
an
active
context
and
a
value
to
be
expanded.
The
optional
query
inputs
are
two
flags,
document
relative
and
fragment
segments.
A
vocab
,
that
specifying
whether
value
can
be
interpreted
as
a
relative
IRI
is
an
IRI
that
is
relative
some
other
absolute
against
the
document's
base
IRI
;
in
or
the
case
of
JSON-LD
active
context's
vocabulary
mapping
,
respectively,
and
a
local
context
and
a
map
defined
to
be
used
when
this
algorithm
is
used
during
Context
Processing
.
If
not
passed,
the
base
location
of
the
document.
two
flags
are
set
to
false
and
local
context
and
defined
are
initialized
to
null
.
:
),
it
is
either
an
absolute
IRI
:
).
_
)
or
suffix
begins
with
double-forward-slash
(
//
),
return
value
Previous
versions
of
this
specification
used
@base
and
@vocab
to
define
invalid
IRI
prefixes
used
to
resolve
relative
IRIs
.
It
was
determined
that
this
added
too
much
complexity,
but
the
issue
can
be
re-examined
in
the
future
based
on
community
input.
mapping
error
has
been
detected
and
processing
is
aborted.
Some
keys
This
algorithm
expands
a
JSON-LD
document,
such
that
all
context
definitions
are
removed,
all
terms
and
compact
IRIs
are
expanded
to
absolute
IRIs
,
blank
node
identifiers
,
or
keywords
and
all
JSON-LD
values
are
expressed
using
in
arrays
in
expanded
form
.
s.
This
section
defines
is
non-normative.
Starting with its root element , we can process the JSON-LD document recursively, until we have a fully expanded result . When expanding an element , we can treat each one differently according to its type, in order to break down the problem:
Finally, after ensuring result is in an array , we return result .
The
algorithm
for
generating
a
compact
IRI
takes
three
input
variables:
an
active
context
,
an
active
property
,
and
an
element
to
be
expanded.
To
begin,
the
active
context
is
set
to
the
result
of
performing,
Context
Processing
on
the
passed
expandContext
,
or
empty
if
expandContext
is
null
,
active
property
is
set
to
null
,
and
element
is
set
to
the
JSON-LD
input
.is:
@graph
,
drop
the
free-floating
scalar
by
returning
null
.
@list
or
its
container
mapping
is
set
to
@list
,
the
expanded
item
must
not
be
list
of
lists
error
has
been
detected
and
processing
is
aborted.
0
@context
,
false
.
@context
key
as
local
context
.
@context
,
continue
to
the
:
)
nor
it
is
a
keyword
,
drop
key
by
continuing
to
the
next
@list
:
@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
string
,
an
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
active
context
,
value
,
and
true
for
document
relative
.
@container
@type
and
value
is
neither
a
string
nor
an
array
of
strings
,
an
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
active
context
,
true
for
vocab
,
and
true
for
document
relative
to
expand
the
value
or
each
of
its
items.
@set
@graph
,
@graph
for
active
property
,
and
value
for
element
.
true
@value
and
invalid
value
object
value
error
has
been
detected
and
processing
is
aborted.
Otherwise,
set
expanded
value
to
value
.
If
expanded
value
is
null
,
set
the
@list
,
continue
@value
member
of
result
to
null
and
continue
with
the
next
@type
member
depends
on
the
existence
of
an
@value
member.
@language
and
value
is
not
a
string
,
an
invalid
language-tagged
string
error
has
been
detected
and
processing
is
aborted.
Otherwise,
set
expanded
value
to
lowercased
value
.
container
@index
and
value
is
not
a
string
,
an
invalid
@index
value
error
has
been
detected
and
processing
is
aborted.
Otherwise,
set
expanded
value
to
value
.
@list
:
@graph
,
continue
list
of
lists
@set
,
@reverse
and
value
is
not
a
JSON
object
,
an
invalid
@reverse
value
containing
only
the
property
@list
error
has
been
detected
and
false
@reverse
as
active
property
,
and
container
@reverse
member,
i.e.,
properties
that
are
reversed
twice,
execute
for
each
of
its
property
and
item
the
following
steps:
true
,
clear
terms
,
set
highest
rank
to
rank
,
@reverse
:
@reverse
member,
create
one
and
@reverse
member
in
result
using
the
variable
reverse
map
.
@reverse
:
invalid
reverse
property
value
has
been
detected
and
@language
and
value
is
a
JSON
object
invalid
language
map
value
error
has
been
detected
and
processing
is
@value
-
item
)
and
(
@language
-lowercased
language
).
@index
and
@type
@index
,
add
the
key-value
pair
(
@container
@index
@list
and
expanded
value
is
not
already
a
list
object
,
convert
expanded
value
to
a
list
object
by
first
setting
it
to
an
array
containing
only
expanded
value
if
it
is
not
already
an
array
,
and
@list
-
expanded
value
.
@reverse
member,
create
one
and
@reverse
member
in
result
using
the
invalid
reverse
property
@list
:
value
has
been
detected
and
processing
is
aborted.
@type
coercion
for
term
,
term
rank
is
@value
:
3
@value
,
@language
,
1
@type
,
0
@index
.
@value
@language
@type
invalid
value
object
@language
@value
key
is
null
,
@language
@value
member
is
not
a
string
and
result
contains
the
@language
,
invalid
language-tagged
value
error
has
been
detected
(only
strings
can
be
language-tagged)
and
processing
is
@language
@type
invalid
typed
value
@type
@type
@set
@list
:
@language
,
term
rank
@index
.
Otherwise,
an
invalid
set
or
list
object
error
has
been
detected
and
processing
is
aborted.
1
@set
,
@id
@language
,
3
@graph
,
@type
@value
@language
@list
,
1
@id
,
If,
after
the
above
algorithm
is
run,
the
result
is
a
JSON
object
that
contains
only
an
@graph
key,
set
the
result
to
the
value
of
@graph
's
value.
Otherwise,
if
the
result
is
null
,
set
it
to
an
empty
array
.
Finally,
if
the
result
is
not
an
array
,
then
set
the
result
to
an
array
containing
only
the
result.
Some
values
in
JSON-LD
can
be
expressed
in
a
compact
form.
form
.
These
values
are
required
to
be
expanded
at
times
when
processing
JSON-LD
documents.
The
algorithm
for
expanding
a
A
value
takes
an
active
property
and
active
context
.
It
is
implemented
as
follows:
said
to
be
in
expanded
form
after
the
application
of
this
algorithm.
value
This
section
is
null
,
the
value
non-normative.
is
already
expanded.
If
active
property
is
@graph
or
has
a
type
mapping
in
the
target
of
an
active
context
set
to
@id
coercion,
expand
the
value
into
an
or
@vocab
,
a
JSON
object
with
a
key-value
pair
where
the
key
is
single
member
@id
and
the
whose
value
is
the
expanded
IRI
according
to
result
of
using
the
IRI
Expansion
algorithm
rules.
Otherwise,
if
active
property
on
value
is
not
returned.
Otherwise,
the
result
will
be
a
keyword
,
then
expand
value
into
JSON
object
containing
an
object:
Set
the
first
key-value
pair
to
@value
and
the
unexpanded
member
whose
value
.
If
the
active
property
is
the
target
of
typed
literal
coercion,
set
the
second
key-value
pair
to
passed
value
.
Additionally,
an
@type
and
the
associated
coercion
datatype
expanded
according
to
the
IRI
Expansion
rules.
Otherwise,
member
will
be
included
if
there
is
a
type
mapping
associated
with
the
active
property
is
the
target
of
language
tagging,
set
the
second
key-value
pair
to
or
an
@language
and
member
if
value
of
the
is
a
string
and
there
is
language
tagging
from
mapping
associated
with
the
active
context
property
.
Otherwise,
value
is
already
expanded.
4.6
Value
Compaction
Some
values,
such
as
IRIs
and
typed
literals
,
may
be
expressed
in
an
expanded
form
in
JSON-LD.
These
values
are
required
to
be
compacted
at
times
when
processing
JSON-LD
documents.
The
algorithm
for
compacting
an
expanded
value
value
takes
three
required
inputs:
an
active
context
,
an
active
property
,
and
active
context
.
It
is
implemented
as
follows:
a
value
to
expand.
@graph
@id
,
return
a
new
JSON
object
containing
a
single
key-value
pair
where
the
@id
@vocab
,
return
a
@id
,
and
the
@id
@value
@value
@type
@type
@language
to
result
and
set
its
value
@language
to
result
and
set
its
value
Expansion
is
the
process
of
taking
This
algorithm
compacts
a
JSON-LD
document
and
applying
a
context
document,
such
that
all
IRI
,
datatypes,
and
literal
values
are
expanded
so
that
the
given
context
is
no
longer
necessary.
applied.
This
must
result
in
shortening
any
applicable
IRIs
to
terms
or
compact
IRIs
,
any
applicable
keywords
to
keyword
aliases
,
and
any
applicable
JSON-LD
document
expansion
is
typically
used
values
expressed
in
expanded
form
to
simple
values
such
as
a
part
of
other
JSON-LD
API
methods.
strings
or
numbers
.
For
example,
assume
the
following
JSON-LD
input
document:
{
"@context":
{
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type", "@id"
}
},
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
This
section
is
non-normative.
Running
the
JSON-LD
Expansion
algorithm
against
Starting
with
its
root
element
,
we
can
process
the
JSON-LD
input
document
provided
above
would
recursively,
until
we
have
a
fully
compacted
result
.
When
compacting
an
element
,
we
can
treat
each
one
differently
according
to
its
type,
in
order
to
break
down
the
following
output:
problem:
@index
or
@language
maps.
The
final
output
is
a
JSON
object
with
a
@context
key,
if
a
non-empty
context
was
given,
where
the
JSON
object
is
either
result
or
a
wrapper
for
it
where
result
appears
as
the
value
of
an
(aliased)
@graph
key
because
result
contained
two
or
more
items
in
an
array
.
The
algorithm
takes
three
five
required
input
variables:
an
active
context
,
an
inverse
context
,
an
active
property
,
and
an
element
to
be
expanded.
compacted,
and
a
flag
compactArrays
.
To
begin,
the
active
context
is
set
to
the
result
of
performing,
performing
Context
Processing
on
the
passed
context
,
or
to
,
the
initial
inverse
context
if
context
is
null
set
to
the
result
of
performing
the
Inverse
Context
Creation
algorithm
on
active
context
,
the
active
property
is
set
to
null
,
and
element
is
set
to
the
result
of
performing
the
Expansion
algorithm
on
the
JSON-LD
input
,
and,
if
not
passed,
compactArrays
is
set
to
true
.
@container
1
),
active
property
has
no
container
mapping
in
active
context
,
and
compactArrays
is
true
,
set
result
to
@value
or
@id
member
and
the
result
of
using
the
Value
Compaction
algorithm
,
passing
active
context
,
inverse
context
,
active
property
,and
element
as
value
is
a
scalar
,
return
that
result.
@reverse
,
otherwise
to
false
.
@list
@id
@type
:
@type
,
false
otherwise.
@type
array
:
@context
1
@context
@reverse
:
@reverse
compactArrays
is
false
and
value
is
not
an
array
,
set
value
to
a
@value
,
@reverse
for
iri
.
@id
@index
and
active
property
has
a
container
mapping
in
active
context
that
is
@index
,
then
the
@index
container,
drop
the
@index
property
by
continuing
to
@type
@index
,
@value
,
or
@language
:
@list
,
otherwise
pass
the
key's
associated
value
for
element
.
@list
and
any
entry
in
value
is
:
@list
@index
,
then
add
a
key-value
pair
to
compacted
item
where
the
key
is
the
result
of
the
IRI
Compaction
algorithm
,
passing
active
context
,
inverse
context
,
@index
as
iri
,
and
@index
key
in
expanded
item
as
value
.
compaction
to
list
of
lists
error
has
been
detected
and
processing
is
aborted.
@list
@language
@index
:
@list
@language
@value
,
then
set
compacted
item
to
the
value
@value
key.
compactArrays
or
property
is
false
,
container
is
@id
,
@set
or
@type
@list
,
or
expanded
property
is
@value
,
@list
or
@language
.
@graph
and
compacted
item
is
not
an
array
,
set
it
to
a
new
array
containing
only
compacted
item
.
If,
after
the
processed
element
algorithm
outlined
above
is
run,
the
result
result
is
an
array
,
replace
it
with
a
new
JSON
object
with
a
single
member
whose
key
is
the
result
of
using
the
IRI
Compaction
algorithm
,
passing
active
context
,
inverse
context
,
and
@graph
as
iri
and
whose
value
is
the
array
result
.
Finally,
if
a
non-empty
context
has
been
passed,
add
an
@value
@context
property
member
to
result
and
set
its
value
to
the
passed
context
.
When
there
is
more
than
one
other
property,
which
can
either
term
that
could
be
@language
or
@type
with
chosen
to
compact
an
IRI
,
it
has
to
be
ensured
that
the
term
selection
is
both
deterministic
and
represents
the
most
context-appropriate
choice
whilst
taking
into
consideration
algorithmic
complexity.
In
order
to
make
term
selections,
the
concept
of
an
inverse
context
is
introduced.
An
inverse
context
is
essentially
a
string
reverse
lookup
table
that
maps
container
mappings
,
type
mappings
,
and
language
mappings
to
a
simple
term
for
a
given
active
context
.
A
inverse
context
only
needs
to
be
generated
for
an
active
context
value.
if
it
is
being
used
for
compaction
.
To
make
use
of
an
inverse
context
,
a
list
of
preferred
container
mappings
and
the
type
mapping
or
language
mapping
are
gathered
for
a
particular
value
of
@value
equals
null
associated
with
an
IRI
.
These
parameters
are
then
fed
to
the
Term
Selection
algorithm
,
replace
which
will
find
the
term
that
most
appropriately
matches
the
value's
mappings.
element
This
section
is
non-normative.
with
To
create
an
inverse
context
for
a
given
active
context
,
each
term
in
the
value
active
context
is
visited,
ordered
by
length,
shortest
first
(ties
are
broken
by
choosing
the
lexicographically
least
term
).
For
each
term
,
an
entry
is
added
to
the
inverse
context
for
each
possible
combination
of
container
mapping
and
type
mapping
or
language
mapping
that
would
legally
match
the
term
.
Illegal
matches
include
differences
between
a
value's
type
mapping
or
language
mapping
and
that
of
the
term
.
If
a
term
has
no
container
mapping
,
type
mapping
,
or
language
mapping
(or
some
combination
of
these),
then
it
will
have
an
entry
in
the
inverse
context
using
the
special
key
.
This
allows
the
Term
Selection
algorithm
to
fall
back
to
choosing
more
generic
terms
when
a
more
specifically-matching
term
is
not
available
for
a
particular
IRI
and
value
combination.
@value
@none
The algorithm takes one required input: the active context that the inverse context is being created for.
@type
property
@none
.
If
the
active
context
has
a
default
language
,
set
default
language
to
it.
@none
.
If
there
is
a
container
mapping
in
term
definition
,
set
container
to
its
associated
value.
@set
@language
@list
@type
@list
@type
@language
@reverse
@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
mapping
.
@language
member
in
type/language
map
using
the
variable
language
map
.
@graph
@none
@graph
@type
@none
member,
create
one
and
set
its
value
to
the
term
being
processed.
Compaction
is
the
process
of
taking
a
JSON-LD
document
and
applying
This
algorithm
compacts
an
IRI
to
a
context
such
that
the
most
term
or
compact
form
of
the
document
is
generated.
JSON
is
typically
expressed
in
IRI
,
or
a
very
compact,
key-value
format.
That
is,
full
IRIs
are
rarely
used
as
keys.
At
times,
keyword
to
a
JSON-LD
document
may
be
received
keyword
alias
.
A
value
that
is
not
in
its
most
compact
form.
JSON-LD,
via
associated
with
the
API,
provides
a
way
IRI
may
be
passed
in
order
to
compact
a
JSON-LD
document.
For
example,
assume
assist
in
selecting
the
following
JSON-LD
input
document:
most
context-appropriate
term
.
Additionally,
assume
the
following
developer-supplied
JSON-LD
context:
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
}
}
}
This
section
is
non-normative.
Running
If
the
JSON-LD
Compaction
algorithm
given
passed
IRI
is
null
,
we
simply
return
null
.
Otherwise,
we
first
try
to
find
a
term
that
the
context
supplied
above
against
IRI
or
keyword
can
be
compacted
to
if
it
is
relative
to
active
context's
vocabulary
mapping
.
In
order
to
select
the
JSON-LD
input
document
provided
above
most
appropriate
term
,
we
may
have
to
collect
information
about
the
passed
value
.
This
information
includes
which
container
mappings
would
result
be
preferred
for
expressing
the
value
,
and
what
its
type
mapping
or
language
mapping
is.
For
JSON-LD
lists
,
the
type
mapping
or
language
mapping
will
be
chosen
based
on
the
most
specific
values
that
work
for
all
items
in
the
following
output:
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
}
},
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
The
compaction
list.
Once
this
information
is
gathered,
it
is
passed
to
the
Term
Selection
algorithm
also
enables
,
which
will
return
the
developer
most
appropriate
term
to
map
any
expanded
format
into
use.
If
no
term
was
found
that
could
be
used
to
compact
the
IRI
,
an
application-specific
compacted
format.
While
attempt
is
made
compact
the
context
provided
above
mapped
http://xmlns.com/foaf/0.1/name
to
name
,
it
IRI
using
the
active
context's
vocabulary
mapping
,
if
there
is
one.
If
the
IRI
could
have
also
mapped
it
not
be
compacted,
an
attempt
is
made
to
any
arbitrary
string
provided
by
find
a
compact
IRI
.
If
there
is
no
appropriate
compact
IRI
,
the
developer.
4.8.1
Compaction
IRI
is
transformed
to
a
relative
IRI
using
the
document's
base
IRI
.
Finally,
if
the
IRI
or
keyword
still
could
not
be
compacted,
it
is
returned
as
is.
The
This
algorithm
takes
three
input
variables:
required
inputs
and
three
optional
inputs.
The
required
inputs
an
active
context
,
an
active
property
inverse
context
,
and
an
element
the
iri
to
be
compacted.
To
begin,
the
active
context
is
set
to
The
optional
inputs
are
a
value
associated
with
the
result
of
performing
Context
Processing
on
iri
,
a
vocab
flag
which
specifies
whether
the
passed
context
,
iri
should
be
compacted
using
the
active
context's
vocabulary
mapping
,
and
a
reverse
flag
which
specifies
whether
a
reverse
property
is
being
compacted.
If
not
passed,
value
is
set
to
null
,
and
element
is
vocab
and
reverse
are
both
set
to
the
result
of
performing
the
Expansion
Algorithm
on
the
JSON-LD
input
false
.
@none
.
@language
,
and
type/language
value
to
@null
.
These
two
variables
will
keep
track
of
the
@index
,
then
append
the
@index
to
containers
.
@type
,
type/language
value
to
@reverse
,
and
append
@set
to
containers
.
@value
@index
@list
to
containers
.
@list
in
value
.
@none
and
item
type
to
@none
.
@value
:
@language
,
then
set
item
language
to
its
associated
value.
@container
@type
,
set
item
type
to
its
associated
value.
@null
.
@id
.
@value
,
then
set
common
language
to
@none
@list
@none
because
list
items
have
conflicting
types.
@none
and
@none
,
then
stop
processing
items
in
the
list
because
it
has
@list
@none
.
@none
.
@none
@type
and
type/language
value
@language
and
does
not
contain
the
@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
container
mapping
,
and
it
will
be
the
last
container
mapping
@null
.
This
is
the
@reverse
,
append
@reverse
to
preferred
values
.
@id
or
@type
@reverse
and
value
has
an
@id
member:
@id
key
in
value
for
iri
,
true
@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
term
because
terms
with
colons
can't
be
:
),
and
the
substring
of
iri
that
This
algorithm,
invoked
via
the
result
of
performing
IRI
Compaction
algorithm
,
makes
use
of
an
active
context's
inverse
context
to
find
the
term
that
is
best
used
to
compact
on
property
.
Create
an
entry
in
IRI
.
Other
information
about
a
value
associated
with
the
IRI
is
given,
including
which
container
mappings
and
which
type
mapping
or
language
mapping
would
be
best
used
to
express
the
value.
output
This
section
is
non-normative.
The
inverse
context's
entry
for
active
property
the
IRI
will
be
first
searched
according
to
the
preferred
container
mappings
,
in
the
order
that
they
are
given.
Amongst
terms
with
a
matching
container
mapping
,
preference
will
be
given
to
those
with
a
matching
type
mapping
or
language
mapping
,
over
those
without
a
type
mapping
or
language
mapping
.
If
there
is
no
term
with
a
matching
container
mapping
then
the
term
without
a
container
mapping
that
matches
the
given
type
mapping
or
language
mapping
is
selected.
If
there
is
still
no
selected
term
,
then
a
term
with
no
type
mapping
or
language
mapping
will
be
selected
if
available.
No
term
will
be
selected
that
has
a
conflicting
type
mapping
or
language
mapping
.
Ties
between
terms
that
have
the
same
mappings
are
resolved
by
first
choosing
the
shortest
terms,
and
then
by
choosing
the
lexicographically
least
term.
Note
that
these
ties
are
resolved
automatically
because
they
were
previously
resolved
when
the
Inverse
Context
Creation
algorithm
was
used
to
create
the
inverse
context
.
This algorithm has five required inputs. They are: an inverse context , a keyword or IRI iri , an array containers that represents an ordered list of preferred container mappings , a string type/language that indicates whether to look for a term with a matching type mapping or language mapping , and an array representing an ordered list of preferred values for the type mapping or language mapping to look for.
Expansion transforms all values into expanded form in JSON-LD. This algorithm performs the opposite operation, transforming a value into compacted form . This algorithm compacts a value according to the term definition in the given active context that is associated with the value's associated active property .
This section is non-normative.
The
value
to
compact
has
either
an
@id
or
an
@value
member.
For
the
former
case,
if
the
type
mapping
of
active
property
is
set
to
@id
or
@vocab
and
value
consists
of
only
of
an
@id
member
and,
if
if
the
container
mapping
of
active
property
is
set
to
@index
,
an
@index
member,
value
can
be
compacted
to
a
string
by
returning
the
result
of
performing
using
the
IRI
Compaction
algorithm
for
property
to
compact
the
value
associated
with
the
@id
member.
Otherwise,
value
cannot
be
compacted
and
item
using
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
active
context
.
Compact
item
by
recursively
performing
this
algorithm
passing
property
has
a
copy
matching
type
mapping
or
language
mapping
and
there
is
either
no
@index
member
or
the
container
mapping
of
active
property
is
set
to
@index
.
It
can
also
be
done
if
@value
is
the
only
member
in
value
(apart
an
@index
member
in
case
the
container
mapping
of
active
context
property
is
set
to
@index
)
and
either
its
associated
value
is
not
a
string
,
there
is
no
default
language
,
or
there
is
an
explicit
null
language
mapping
for
the
active
property
.
If
This
algorithm
has
four
required
inputs:
an
entry
already
exists
in
output
for
active
property
context
,
convert
it
to
an
array
if
necessary,
inverse
context
,
an
active
property
,
and
append
a
value
to
be
compacted.
@index
member
and
the
container
mapping
associated
to
active
property
is
set
to
@index
,
decrease
number
members
by
1
.
2
,
return
value
as
it
cannot
be
compacted.
@container
@id
member:
1
and
the
type
mapping
of
active
property
is
set
to
@set
@id
,
@id
member
for
iri
.
1
and
the
type
mapping
of
active
property
@vocab
,
return
the
result
of
using
the
IRI
compaction
algorithm
,
passing
active
context
,
inverse
context
,
the
value
@id
member
for
iri
,
and
true
for
vocab
.
@type
member
whose
value
matches
the
@value
member
of
value
.
@language
member
whose
value
matches
the
language
mapping
of
active
property
,
@graph
@value
1
and
@context
@value
member
is
not
a
string
,
or
the
active
context
has
no
default
language
,
or
the
language
mapping
of
active
property
@value
member.
A
This
algorithm
flattens
an
expanded
JSON-LD
document
may
be
converted
between
other
RDF-compatible
document
formats
using
the
algorithms
specified
in
this
section.
The
JSON-LD
Processing
Model
describes
processing
rules
for
extracting
RDF
from
a
JSON-LD
document,
and
for
transforming
an
array
of
Quad
retrieved
by
processing
another
serialization
format
into
JSON-LD.
Note
that
many
uses
of
JSON-LD
may
not
require
generation
collecting
all
properties
of
RDF.
The
processing
algorithms
described
in
this
section
are
provided
a
node
in
order
to
demonstrate
how
one
might
implement
a
JSON-LD
to
RDF
processor.
Conformant
implementations
are
only
required
to
produce
the
same
type
single
JSON
object
and
number
labeling
all
blank
nodes
with
blank
node
identifiers
.
This
resulting
uniform
shape
of
quads
during
the
output
process
and
are
not
document,
may
drastically
simplify
the
code
required
to
implement
the
algorithm
exactly
as
described.
process
JSON-LD
data
in
certain
applications.
This section is non-normative.
JSON-LD
First,
a
node
map
is
intended
to
have
an
easy
to
parse
grammar
that
closely
models
existing
practice
in
generated
using
the
Node
Map
Generation
algorithm
which
collects
all
properties
of
a
node
in
a
single
JSON
for
describing
object
representations.
This
allows
.
In
the
use
of
existing
libraries
for
parsing
JSON.
next
step,
the
node
map
is
converted
to
a
JSON-LD
document
in
flattened
document
form
.
Finally,
if
a
context
has
been
passed,
the
flattened
document
is
compacted
using
the
Compaction
algorithm
before
being
returned.
As
with
other
grammars
The
algorithm
takes
two
input
variables,
an
element
to
flatten
and
an
optional
context
used
for
describing
Linked
Data
,
to
compact
the
flattened
document.
If
not
passed,
context
is
set
to
null
.
@default
and
whose
value
is
an
empty
JSON
object
.
@default
member
of
node
map
,
which
is
a
JSON
object
representing
the
default
graph
.
@default
,
perform
the
following
steps:
@id
member
whose
value
is
set
to
graph
name
.
IRI
@graph
@graph
member
of
entry
.
@graph
keyword
(or
its
alias)
at
the
top-level,
even
if
the
context
is
@graph
array
.
This
ensures
that
the
returned
document
has
a
Data
described
with
JSON-LD
may
be
considered
to
be
This
algorithm
creates
a
graph
made
up
JSON
object
node
map
holding
an
indexed
representation
of
subject
the
graphs
and
object
nodes
represented
in
the
passed
expanded
document.
All
nodes
related
via
that
are
not
uniquely
identified
by
an
IRI
get
assigned
a
property
(new)
blank
node
identifier
.
Specific
implementations
may
also
choose
to
operate
on
The
resulting
node
map
will
have
a
member
for
every
graph
in
the
document
as
whose
value
is
another
object
with
a
normal
JSON
description
of
objects
having
attributes.
Both
approaches
member
for
every
node
represented
in
the
document.
The
default
graph
is
stored
under
the
@default
member,
all
other
graphs
are
valid
ways
to
interact
with
JSON-LD
documents.
stored
under
their
graph
name
.
This section is non-normative.
The
following
examples
show
simple
transformations
of
algorithm
recursively
runs
over
an
expanded
JSON-LD
documents
to
Turtle
[
TURTLE-TR
].
The
first
example
uses
a
simple
document
containing
a
simple
FOAF
profile:
{
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
"@id": "http://greggkellogg.net/foaf#me",
"@type": "foaf:Person",
"foaf:name": "Gregg Kellogg",
"foaf:knows": {
"@type": "foaf:Person",
"foaf:name": "Manu Sporny"
}
}
This
translates
fairly
directly
to
collect
all
properties
of
a
similar
Turtle
document:
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
<http://greggkellogg.net/foaf#me> a foaf:Person;
foaf:name "Gregg Kellogg";
foaf:knows
[
node
in
a
foaf:Person;
foaf:name
"Manu
Sporny"].
single
JSON
object
.
The
actual
parsing
steps
first
require
that
algorithm
constructs
a
JSON
object
node
map
whose
keys
represent
the
graph
names
used
in
the
JSON-LD
document
be
expanded,
to
eliminate
(the
default
graph
is
stored
under
the
key
)
and
whose
associated
values
are
JSON
objects
@context
:
[{
"@id": "http://greggkellogg.net/foaf#me",
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}],
"http://xmlns.com/foaf/0.1/knows": [{
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}]
}]
}]
The
process
of
translating
this
to
RDF
then
operates
over
each
subject
definition
@default
to
find
which
index
the
nodes
in
the
graph
.
If
a
subject,
each
property
property's
to
find
an
RDF
predicate
,
and
each
value
is
a
node
object
,
it
is
replace
by
a
node
object
consisting
of
that
property
to
find
only
an
@id
member.
If
a
node
object
.
In
this
case,
each
property
has
just
a
single
object:
no
foaf:name
@id
identifies
member
or
it
is
identified
by
a
literal
blank
node
identifier
,
and
foaf:knows
identifies
a
second
subject
definition
new
blank
node
identifier
similar
to
Turtle's
blankNodePropertyList
.
After
expansion,
JSON-LD
numbers
,
booleans
,
typed-
and
language-tagged-
literals
,
and
IRIs
is
generated.
This
relabeling
of
blank
node
identifiers
become
explicit,
and
can
is
also
be
directly
transformed
into
their
RDF
representations.
[{
"@id": "http://greggkellogg.net/foaf#me",
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}],
"http://xmlns.com/foaf/0.1/currentProject": [{"@id": "http://json-ld.org/"}],
"http://xmlns.com/foaf/0.1/birthday": [{
"@value": "1957-02-27",
"@type": "http://www.w3.org/2001/XMLSchema#date"
}],
"http://xmlns.com/foaf/0.1/knows": [{
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}]
}]
}]
Translates
to:
done
for
properties
and
values
of
@type
.
The
algorithm
below
is
designed
for
in-memory
implementations
with
random
access
takes
as
input
an
expanded
JSON-LD
document
element
and
a
reference
to
a
JSON
object
elements.
A
conforming
JSON-LD
processor
implementing
RDF
conversion
must
implement
a
processing
algorithm
that
results
in
node
map
.
Furthermore
it
has
the
same
set
of
RDF
Quads
optional
parameters
active
graph
that
the
following
algorithm
generates:
The
algorithm
takes
five
input
variables:
a
element
(which
defaults
to
be
converted,
@default
),
an
active
subject
,
active
property
,
and
graph
name
.
To
begin,
the
a
reference
to
a
JSON
object
list
.
If
not
passed,
active
subject
,
active
property
,
and
graph
name
list
are
set
to
null
.
@type
member,
perform
for
each
item
the
following
steps:
@id
whose
value
is
item
.
@value
@list
member
of
list
.
@list
member,
perform
the
following
steps:
@list
whose
value
@type
@list
member
for
element
,
active
graph
,
active
subject
,
active
property
@id
member,
set
id
to
its
value
and
remove
the
member
from
element
.
If
id
is
a
blank
node
identifier
,
replace
it
with
a
newly
generated
blank
node
identifier
passing
id
for
identifier
.
@value
@id
whose
value
is
@id
whose
value
is
id
.
@list
member
of
list
.
@type
@type
key
of
node
unless
it
xsd:boolean
.
@type
member
from
element
.
@type
@index
@index
member
of
node
to
its
value.
If
node
has
already
an
@index
member
with
a
conflicting
indexes
error
has
been
detected
and
processing
is
aborted.
Otherwise,
continue
by
removing
the
@index
member
from
element
.
@language
@reverse
@id
whose
value
is
id
.
@reverse
member
of
element
.
xsd:string
@reverse
@list
@graph
member,
recursively
invoke
this
algorithm
passing
the
value
of
the
@graph
member
for
element
,
node
map
,
and
id
for
active
graph
before
removing
the
@graph
member
from
element
.
This
algorithm
is
used
to
determine
if
two
generate
new
blank
node
identifiers
using
or
to
relabel
an
existing
blank
node
identifier
to
avoid
collision
by
the
return
value
as
introduction
of
new
ones.
This section is non-normative.
The
simplest
case
is
if
there
exists
already
a
blank
node
identifier
in
the
active
object
identifier
map
for
the
passed
identifier
,
in
which
case
it
is
simply
returned.
Otherwise,
a
new
blank
node
identifier
is
generated
by
concatenating
the
string
_:b
and
the
counter
.
If
active
object
the
passed
identifier
is
not
null
:
,
an
entry
is
created
in
the
identifier
map
associating
the
identifier
with
the
blank
node
identifier
.
Finally,
the
counter
is
increased
by
one
and
the
new
blank
node
identifier
is
returned.
The
algorithm
takes
a
single
input
variable
identifier
which
may
be
null
.
Between
its
executions,
the
algorithm
needs
to
keep
an
identifier
map
to
relabel
existing
blank
node
identifiers
consistently
and
a
counter
to
generate
new
blank
node
identifiers
.
The
counter
is
initialized
to
0
by
default.
Quad
_:b
1
.
This
section
describes
algorithms
to
transform
a
@id
property,
JSON-LD
document
to
an
RDF
dataset
and
vice
versa.
The
algorithms
are
designed
for
in-memory
implementations
with
random
access
to
JSON
object
elements.
Throughout
this
section,
the
value
must
following
vocabulary
prefixes
are
used
in
compact
IRIs
:
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
algorithms
converts
a
JSON-LD
document
to
an
RDF
dataset
.
Please
note
that
RDF
does
not
allow
a
blank
node
to
be
used
as
a
string
graph
name
or
property
,
set
the
active
subject
while
JSON-LD
does.
JSON-LD-RDF
Converters
can
work
around
this
restriction,
when
converting
JSON-LD
to
RDF,
by
converting
such
blank
nodes
to
IRIs
,
minting
new
"Skolem
IRIs"
as
per
Replacing
Blank
Nodes
with
IRIs
of
[
RDF11-CONCEPTS
].
Note:
This
feature
is
"at
risk"
and
may
be
removed
from
this
specification
based
on
feedback.
Please
send
feedback
to
public-rdf-comments@w3.org
.
For
the
previously
expanded
value
(either
current
status
see
features
"at
risk"
in
JSON-LD
1.0
RDF
does
not
currently
allow
a
blank
node
to
be
used
as
graph
name
or
an
property
,
while
JSON-LD
does.
JSON-LD-RDF
Converters
can
work
around
this
restriction,
when
converting
JSON-LD
to
RDF,
by
converting
such
blank
nodes
to
IRIs
,
minting
new
"Skolem
IRIs"
as
per
IRI
Replacing
Blank
Nodes
with
IRIs
of
[
RDF11-CONCEPTS
).
Otherwise,
if
].
Based
on
feedback
from
implementors
the
Working
Group
may
decide
to
disallow
blank
nodes
as
graph
names
and
properties
in
JSON-LD.
If
this
change
would
affect
you,
be
sure
to
send
in
a
comment.
element
This
section
is
non-normative.
does
not
have
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
node
object
.
Each
graph
from
the
node
map
is
processed
to
extract
RDF
triples
,
to
which
any
(non-default)
graph
name
is
applied
to
create
an
RDF
dataset
.
Each
node
object
in
the
node
map
has
an
@id
property,
set
member
which
corresponds
to
the
active
RDF
subject
,
the
other
members
represent
RDF
predicates
.
Each
member
value
is
either
an
IRI
to
newly
generated
or
blank
node
identifier
or
can
be
transformed
to
an
RDF
literal
to
generate
an
RDF
triple
.
Lists
are
transformed
into
an
RDF
Collection
using
the
List
to
RDF
Conversion
algorithm.
The algorithm takes a JSON-LD document element and returns an RDF dataset .
@type
,
rdf:type
.
Otherwise,
if
property
is
@graph
,
@list
key
from
item
and
list
triples
.
Append
first
a
triple
composed
of
subject
,
property
@default
,
add
triples
to
the
default
graph
in
dataset
.
This
algorithm
takes
a
node
object
or
value
object
and
transforms
it
into
an
RDF
resource
to
active
subject
be
used
as
the
object
of
an
RDF
triple
.
This section is non-normative.
Value objects are transformed to RDF literals as described in section 10.6 Data Round Tripping whereas node objects are transformed to IRIs or blank node identifiers .
The algorithm takes as its sole argument item which must be either a value object or node object .
@id
member.
@value
member
in
item
.
@type
member
of
item
or
null
if
true
or
false
which
is
the
canonical
lexical
form
as
xsd:boolean
.
xsd:double
,
convert
value
to
a
string
IRI
xsd:double
as
defined
in
[
XMLSCHEMA11-2
]
and
described
in
section
10.6
Data
Round
Tripping
.
If
datatype
is
null
,
set
it
to
xsd:double
.
xsd:integer
,
convert
value
to
a
string
Quad
xsd:integer
as
defined
in
[
XMLSCHEMA11-2
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
an
array
a
list
object
of
values
and
adding
them
to
a
newly
created
transforming
it
into
an
RDF
Collection
(see
as
defined
in
RDF
Semantics
[
RDF-SCHEMA
RDF-MT
])
by
linking
].
This section is non-normative.
For
each
element
of
the
list
using
a
new
blank
node
identifier
is
allocated
which
is
used
to
generate
rdf:first
and
triples
.
The
algorithm
returns
the
list
rdf:next
,
terminating
rdf:rest
with
head,
which
is
either
the
the
first
allocated
blank
node
identifier
or
rdf:nil
using
if
the
following
sequence:
list
is
empty.
The
algorithm
is
invoked
with
takes
two
inputs:
an
array
array
,
the
active
property
list
and
returns
a
value
to
be
used
as
an
active
object
empty
array
in
list
triples
used
for
returning
the
calling
location.
generated
triples
.
rdf:nil
.
rdf:first
as
the
active
property
.
Process
,
and
the
rdf:nil
.
rdf:rest
,
and
rest
rdf:nil
if
bnodes
is
empty.
In
some
cases,
data
exists
natively
in
Triples
or
Quads
form;
for
example,
if
the
data
was
originally
represented
in
an
RDF
graph
or
triple/quad
store.
This
algorithm
is
designed
to
simply
translate
converts
an
array
RDF
dataset
consisting
of
Quads
a
default
graph
and
zero
or
more
named
graphs
into
a
JSON-LD
document.
Note:
This
feature
is
"at
risk"
values
having
a
datatype
and
may
be
removed
from
this
specification
based
on
feedback.
Please
send
feedback
to
public-rdf-comments@w3.org
.
For
the
current
status
see
features
"at
risk"
in
JSON-LD
1.0
In
the
interest
of
xsd:string
,
space
and
simplicity,
the
steps
necessary
for
handling
lists
of
lists
have
been
omitted.
Such
lists
and
their
elements
must,
recursively,
be
handled
like
other
lists.
Lists
of
lists
can,
however,
not
be
represented
in
JSON-LD
using
@type
@list
must
not
;
they
have
to
be
represented
as
a
set
to
of
interlinked
node
objects
using
RDF's
and
xsd:string
rdf:first
the
resulting
value
must
have
only
a
@value
rdf:rest
property.
properties.
The
Working
Group
might
either
require
handling
of
lists-of-lists
or
forbid
them
in
JSON-LD
1.0.
Implementers
please
send
reports
of
whether
you
are
able
to
implement
handling
for
lists-of-lists
or
would
instead
request
such
structures
be
disallowed.
The
conversion
algorithm
takes
a
single
parameter
input
This
section
is
non-normative.
Iterate
through
each
graph
in
the
dataset,
converting
RDF
Collections
into
a
list
and
generating
a
JSON-LD
document
in
expanded
form
of
an
array
of
for
all
RDF
literals
,
IRIs
and
blank
node
identifiers
.
If
the
use
native
types
flag
is
set
to
true
,
RDF
literals
with
a
datatype
IRI
that
equals
or
Quad
xsd:integer
xsd:double
are
converted
to
a
JSON
numbers
and
RDF
literals
with
a
datatype
IRI
representations.
that
equals
xsd:boolean
are
converted
to
true
or
false
based
on
their
lexical
form
as
described
in
section
10.6
Data
Round
Tripping
.
The algorithm takes two required inputs: an RDF dataset and a flag use native types that defaults to true .
nodeMap
and
listMap
,
each
,
whose
value
is
an
an
empty
JSON
object
.
@default
whose
value
is
set
to
reference
default
graph
.
nodeMap
member
of
default
graph
using
the
variable
default
graph
nodes
.
@default
,
otherwise
to
the
nodeMap
and
listMap
,
whose
value
is
an
an
empty
JSON
object
.
@id
whose
value
is
name
.
nodeMap
member
in
graph
object
using
the
variable
node
map
and
listMap
member
using
the
variable
list
map
.
rdf:rest
:
rdf:first
,
first
member
of
the
subject
member
of
list
map
to
the
rdf:rest
:
@id
rest
@id
rdf:type
,
and
@type
,
creating
member
of
node
.
If
no
such
member
exists,
create
one
and
initialize
it
to
an
head
member
of
the
object
listMap
member
in
graph
object
using
the
variable
list
map
.
listMap
member
of
graph
head
and
an
first
keys:
member
it
does
not
represent
the
head
of
a
list
.
Continue
with
the
next
key-value
pair.
head
member
in
entry
@id
@list
first
from
member
of
entry
rest
:
member
of
entry
is
not
rdf:nil
:
rest
member
of
entry
.
first
member
of
entry
to
the
@list
member
of
value
.
@graph
nodeMap
member
of
the
subject
member
of
graph
map
using
the
variable
node
map
.
@graph
member
of
node
.
When
coercing
numbers
This
algorithm
transforms
an
RDF
literal
to
a
JSON-LD
value
object
and
a
RDF
blank
node
or
IRI
to
an
JSON-LD
node
object
.
This section is non-normative.
RDF
literals
are
transformed
to
value
objects
whereas
IRIs
and
blank
node
identifiers
are
transformed
to
node
objects
.
If
the
use
native
types
flag
is
set
to
true
,
RDF
literals
with
a
datatype
IRI
that
equals
xsd:integer
or
xsd:double
are
converted
to
a
JSON
numbers
and
RDF
as
it,
e.g.,
happens
during
Conversion
,
implementers
must
ensure
literals
with
a
datatype
IRI
that
equals
xsd:boolean
are
converted
to
true
or
false
based
on
their
lexical
form
as
described
in
section
10.6
Data
Round
Tripping
.
This algorithm takes two required inputs: a value to be converted to a JSON object and a flag use native types .
rdf:nil
return
a
new
JSON
object
consisting
of
a
single
member
@list
whose
value
is
set
to
an
empty
array
.
This
is
behavior
is
required
by
the
@id
whose
value
is
set
to
value
.
xsd:string
,
set
converted
value
to
the
lexical
form
xsd:boolean
,
set
converted
value
to
true
if
the
lexical
form
of
true
,
or
false
if
it
matches
false
.
If
it
matches
neither,
set
type
to
xsd:boolean
.
xsd:integer
or
xsd:double
and
its
lexical
form
is
a
valid
xsd:integer
or
xsd:double
according
[
XMLSCHEMA11-2
],
set
converted
value
to
the
result
of
@language
to
result
and
set
its
value
to
the
language
tag
of
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
converting
JSON-LD
to
RDF
JSON-native
numbers
are
automatically
type-coerced
to
xsd:integer
or
xsd:double
depending
on
whether
the
number
has
fractions
or
not,
the
boolean
values
true
and
false
are
coerced
to
xsd:boolean
,
and
strings
are
coerced
to
xsd:string
.
The
numeric
or
boolean
values
itself
are
converted
to
canonical
lexical
form
and
,
i.e.,
a
value
in
the
value
space
deterministic
string
representation
as
defined
in
[
XMLSCHEMA11-2
]].
In
other
words,
every
value
must
be
converted
to
a
deterministic
string
representation.
].
The
canonical
lexical
form
of
an
integer
,
i.e.,
a
number
without
fractions
or
a
number
coerced
to
xsd:integer
,
is
a
finite-length
sequence
of
decimal
digits
(
,
0-9
)
with
an
optional
leading
minus
sign;
leading
zeroes
zeros
are
prohibited.
To
convert
the
number
in
In
JavaScript,
implementers
can
use
the
following
snippet
of
code:
code
to
convert
an
integer
to
canonical
lexical
form
:
(value).toFixed(0).toString()
The
canonical
lexical
form
of
a
double
,
i.e.,
a
number
with
fractions
or
a
number
coerced
to
xsd:double
,
consists
of
a
mantissa
followed
by
the
character
,
"E",
E
,
followed
by
an
exponent.
The
mantissa
must
be
is
a
decimal
number.
The
number
and
the
exponent
must
be
is
an
integer.
Leading
zeroes
zeros
and
a
preceding
plus
sign
(
+
)
are
prohibited
in
the
exponent.
If
the
exponent
is
zero,
it
must
be
is
indicated
by
E0
.
For
the
mantissa,
the
preceding
optional
plus
sign
is
prohibited
and
the
decimal
point
is
required.
Leading
and
trailing
zeroes
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
.
To
convert
the
number
in
JavaScript,
implementers
can
use
the
following
snippet
of
code:
Example
24
(value).toExponential().replace(/e\+?/,'E')
xsd:double
's
value
space
is
defined
by
the
IEEE
double-precision
64-bit
floating
point
type
[
IEEE-754-1985
].
Note
When
data
such
as
decimals
need
to
be
normalized,
JSON-LD
authors
should
]
whereas
the
value
space
of
JSON
numbers
is
not
use
values
that
are
going
specified;
when
converting
JSON-LD
to
undergo
automatic
conversion.
This
RDF
the
mantissa
is
due
rounded
to
15
digits
after
the
lossy
nature
of
xsd:double
values.
Authors
should
instead
decimal
point.
In
JavaScript,
implementers
can
use
the
expanded
object
form
following
snippet
of
code
to
set
the
convert
a
double
to
canonical
lexical
form
directly.
:
(value).toExponential(15).replace(/(\d)0*e\+?/,'$1E')
The
canonical
lexical
form
of
the
boolean
values
true
and
false
are
the
strings
true
and
false
.
When
JSON-native
datatypes,
like
number
s,
numbers
,
are
type
coerced,
converted
to
RDF,
lossless
data
round-tripping
can
not
be
guaranted.
Consider
guaranteed
as
rounding
errors
might
occur.
When
converting
RDF
to
JSON-LD
,
similar
rounding
errors
might
occur.
Furthermore,
the
following
code
example:
var myObj1 = {
"@context": {
"number": {
"@id": "http://example.com/vocab#number",
}
},
"number" :
};
// Convert the JSON-LD document to RDF; this converts 42 to a string
var jsonldText = jsonld.toRDF(myObj1, myRdfTripleCollector);
// Convert the RDF triples back to a JavaScript object
var
myObj2
=
jsonld.fromRDF(myRdfTripleCollector.getTriples());
At
this
point,
myObj1
and
myObj2
will
have
different
values
for
datatype
or
the
"number"
property.
lexical
representation
might
be
lost.
An
myObj1
xsd:double
will
have
the
number
42
,
while
with
a
value
of
myObj2
2.0
have
will,
e.g.,
result
in
an
object
consisting
of
@value
xsd:integer
set
to
the
string
with
a
value
of
in
canonical
lexical
form
when
converted
from
RDF
to
JSON-LD
and
back
to
RDF.
It
is
important
to
highlight
that
in
practice
it
might
be
impossible
to
losslessly
convert
an
"42"
2
@type
xsd:integer
set
to
a
number
because
its
value
space
is
not
limited.
While
the
JSON
specification
[
RFC4627
]
does
not
limit
the
expanded
value
space
of
xsd:nonNegativeInteger
.
numbers
either,
concrete
implementations
typically
do
have
a
limited
value
space.
To
ensure
lossless
round-tripping
the
Converting
from
RDF
algorithm
specifies
a
use
native
types
flag
which
controls
whether
RDF
literals
with
a
datatype
IRI
equal
to
xsd:integer
,
xsd:double
,
or
xsd:boolean
are
converted
to
their
JSON-native
counterparts.
If
the
use
native
types
flag
is
set
to
false
,
all
literals
remain
in
their
original
string
representation.
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,
a
JSON-LD
serializer
must
not
backslash-escape
forward
slashes.
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. A conformant JSON-LD API Implementation MUST implement the entirety of the following API.
JsonLdProcessor
Interface
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
conformant
JSON-LD
API
Implementations
MUST
NOT
modify
the
input
parameters.
If
an
error
is
detected,
the
callback
is
invoked
passing
a
JsonLdError
with
the
corresponding
error
code
and
processing
is
stopped.
Note: This feature is "at risk" and may be removed from this specification based on feedback. Please send feedback to public-rdf-comments@w3.org . For the current status see features "at risk" in JSON-LD 1.0
The
definition
of
the
JsonLdProcessor
interface
uses
method
overloading
to
make
the
"options"
parameter
optional.
According
to
the
current
version
of
the
Web
IDL
specification
[
WEBIDL
],
this
would
not
be
supported
as
the
"options"
parameter
(a
dictionary)
and
the
callback
parameter
(a
callback
function)
are
not
distinguishable
.
A
bug
report
has
been
already
been
filed.
If
it
turns
out
that
this
is
not
a
bug,
the
Working
Group
may
change
the
interface
by
swapping
the
"options"
and
"callback"
parameter.
[Constructor]
interface JsonLdProcessor {
void compact (JsonLdInput
input, JsonLdContext
context, JsonLdOptions
options, JsonLdCallback
callback); void compact (JsonLdInput
input, JsonLdContext
context, JsonLdCallback
callback); void expand (JsonLdInput
input, JsonLdOptions
options, JsonLdCallback
callback); void expand (JsonLdInput
input, JsonLdCallback
callback); void flatten (JsonLdInput
input, JsonLdContext
? context, JsonLdOptions
options, JsonLdCallback
callback); void flatten (JsonLdInput
input, JsonLdContext
? context, JsonLdCallback
callback);
};
compact
Compacts the given input using the context according to the steps in the Compaction algorithm :
application/ld+json
or
application/json
or
if
the
document
cannot
be
parsed
as
JSON,
invoke
the
callback
passing
an
loading
document
failed
error.
expandContext
has
been
passed,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
expandContext
as
local
context
.
application/json
and
an
HTTP
Link
Header
[
RFC5988
]
using
the
http://www.w3.org/ns/json-ld#context
link
relation,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
context
referenced
in
the
HTTP
Link
Header
as
local
context
.
compactArrays
flag
in
options
.Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ | The JSON-LD object or array of JSON-LD objects to perform the compaction upon or an IRI referencing the JSON-LD document to compact. |
context |
| ✘ | ✘ |
The
context
to
use
when
compacting
the
input
;
either
in
the
form
of
a
JSON
object
or
as
IRI
. |
options |
| ✘ | ✘ | A set of options to configure the algorithms. This allows, e.g., to set the input document's base IRI . |
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
compact
This
method
is
still
being
discussed
the
same
as
the
compact
method
defined
above
but
without
the
the
options
parameter:
whether
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ | The JSON-LD object or array of JSON-LD objects to perform the compaction upon or an IRI referencing the JSON-LD document to compact. |
context |
| ✘ | ✘ |
The
context
to
use
when
compacting
the
input
;
either
in
the
form
of
a
JSON
object
or
as
IRI
. |
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
expand
Expands the given input according to the steps in the Expansion algorithm :
application/ld+json
or
application/json
or
if
the
document
cannot
be
parsed
as
JSON,
invoke
the
callback
passing
an
loading
document
failed
error.
expandContext
has
been
passed,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
expandContext
as
local
context
.
application/json
and
an
HTTP
Link
Header
[
RFC5988
]
using
the
http://www.w3.org/ns/json-ld#context
link
relation,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
context
referenced
in
the
HTTP
Link
Header
as
local
context
.Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ | The JSON-LD object or array of JSON-LD objects to perform the expansion upon or an IRI referencing the JSON-LD document to expand. |
options |
| ✘ | ✘ | A set of options to configure the used algorithms such. This allows, e.g., to set the input document's base IRI . |
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
expand
This
method
is
the
same
as
the
expand
method
defined
above
but
without
the
the
options
parameter:
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ | The JSON-LD object or array of JSON-LD objects to perform the expansion upon or an IRI referencing the JSON-LD document to expand. |
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
flatten
Flattens the given input and compacts it using the passed context according to the steps in the Flattening algorithm :
application/ld+json
or
application/json
or
if
the
loading
document
failed
error.
expandContext
has
been
passed,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
expandContext
as
local
context
.
application/json
and
an
HTTP
Link
Header
[
RFC5988
]
using
the
http://www.w3.org/ns/json-ld#context
link
relation,
update
the
active
context
using
the
Context
Processing
algorithm
,
passing
the
context
referenced
in
the
HTTP
Link
Header
as
local
context
.
0
)
to
be
used
by
the
Generate
Blank
Node
Identifier
algorithm
.
compactArrays
flag
in
options
(which
is
internally
passed
to
the
Compaction
algorithm
).
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ |
The
JSON-LD
object
or
|
context |
| ✔ | ✘ |
The
context
to
use
when
compacting
the
flattened
input
;
either
in
the
form
of
a
JSON
object
or
as
IRI
.
If
null
is
passed,
the
result
will
not
be
compacted
but
kept
in
expanded
form.
|
options |
| ✘ | ✘ | A set of options to configure the used algorithms such. This allows, e.g., to set the input document's base IRI . |
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
flatten
This
method
is
the
same
as
the
flatten
method
defined
above
but
without
the
the
options
parameter:
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
input |
| ✘ | ✘ | The JSON-LD object or array of JSON-LD objects or an IRI referencing the JSON-LD document to flatten. |
context |
| ✔ | ✘ |
The
context
to
use
when
compacting
the
flattened
input
;
either
in
the
form
of
a
JSON
object
or
as
IRI
.
If
null
is
passed,
the
result
will
not
be
compacted
but
kept
in
expanded
form.
|
callback |
| ✘ | ✘ |
A
callback
that
is
called
when
processing
completed
successfully
on
the
given
input
,
or
a
fatal
error
prevented
processing
from
completing.
|
void
typedef
(
object
or
object[]
or
DOMString
)
JsonLdInput
;
The
identifier
JsonLdInput
is
used
to
refer
to
the
(object
or
object[]
or
DOMString)
type.
typedef
(
object
or
DOMString
)
JsonLdContext
;
The
identifier
JsonLdContext
is
used
to
refer
to
the
(object
or
DOMString)
type.
JSON-LD API Implementations utilize callbacks in order to exchange information in an asynchronous manner with applications. This section details the parameters of those callbacks.
The
JsonLdCallback
is
called
when
an
API
method
of
JsonLdProcessor
has
been
completed,
either
successfully
or
by
a
fatal
error.
callback
JsonLdCallback
=
void
(
JsonLdError
error
,
optional
(object
or
object[])
document
);
JsonLdCallback
Parameters
error
of
type
JsonLdError
document
of
type
(object
or
object[])
The
LoadContextCallback
defines
the
callback
that
custom
context
loaders
have
to
implement
to
be
used
to
retrieve
remote
contexts.
callback
LoadContextCallback
=
void
(
DOMString
url
,
ContextLoadedCallback
callback
);
LoadContextCallback
Parameters
url
of
type
DOMString
callback
of
type
ContextLoadedCallback
The
ContextLoadedCallback
is
called
in
response
to
a
call
of
the
LoadContextCallback
.
callback
ContextLoadedCallback
=
void
(
JsonLdError
error
,
optional
DOMString
url
,
optional
DOMString
context
);
ContextLoadedCallback
Parameters
error
of
type
JsonLdError
JsonLdErrorCode
of
loading
remote
context
failed
.
url
of
type
DOMString
context
of
type
DOMString
This section describes datatype definitions used within the JSON-LD API.
The
JsonLdOptions
type
is
used
to
pass
various
options
to
the
JsonLdProcessor
methods.
dictionary JsonLdOptions { DOMString base; boolean compactArrays = true; LoadContextCallback
loadContext; (object? or DOMString) expandContext = null; DOMString processingMode = "json-ld-1.0";
};
JsonLdOptions
Members
base
of
type
DOMString
Note: This feature is "at risk" and may be removed from this specification based on feedback. Please send feedback to public-rdf-comments@w3.org . For the current status see features "at risk" in JSON-LD 1.0
The
default
value
of
base
in
JsonLdOptions
implies
that
all
IRIs
that
cannot
be
compacted
otherwise
are
transformed
to
relative
IRIs
during
compaction.
To
avoid
that
data
is
being
lost,
developers
thus
have
to
store
the
base
IRI
along
with
the
compacted
document.
Based
on
implementer
feedback,
the
Working
Group
may
decide
to
change
the
default
value
to
null
,
meaning
that
IRIs
are
not
automatically
compacted
to
relative
IRIs.
compactArrays
of
type
boolean
,
defaulting
to
true
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.
expandContext
of
type
(object?
or
DOMString)
,
defaulting
to
null
loadContext
of
type
LoadContextCallback
processingMode
of
type
DOMString
,
defaulting
to
"json-ld-1.0"
json-ld-1.0
,
the
JSON-LD
json-ld
as
they
are
reserved
for
future
versions
of
this
specification.
The
JsonLdError
type
is
used
to
report
processing
errors
to
a
well-known
location.
JsonLdCallback
.
dictionary JsonLdError {
JsonLdErrorCode
code;
DOMString? message = null;
};
JsonLdError
Members
code
of
type
JsonLdErrorCode
message
of
type
DOMString
,
nullable,
defaulting
to
null
The
JsonLdErrorCode
represents
the
collection
of
valid
JSON-LD
error
codes.
enum JsonLdErrorCode {
"loading document failed",
"list of lists",
"invalid @index value",
"conflicting indexes",
"invalid @id value",
"invalid local context",
"loading remote context failed",
"invalid remote context",
"recursive context inclusion",
"invalid base IRI",
"invalid vocab mapping",
"invalid default language",
"keyword redefinition",
"invalid term definition",
"invalid reverse property",
"invalid IRI mapping",
"cyclic IRI mapping",
"invalid keyword alias",
"invalid type mapping",
"invalid language mapping",
"colliding keywords",
"invalid container mapping",
"invalid type value",
"invalid value object",
"invalid value object value",
"invalid language-tagged string",
"invalid language-tagged value",
"invalid typed value",
"invalid set or list object",
"invalid language map value",
"compaction to list of lists",
"invalid reverse property map",
"invalid @reverse value",
"invalid reverse property value"
};
Enumeration description | |
---|---|
loading
document
failed
| The document could not be loaded or parsed as JSON. |
list
of
lists
| A list of lists was detected. List of lists are not supported in this version of JSON-LD due to the algorithmic complexity associated with conversion to RDF. |
invalid
@index
value
|
An
@index
member
was
encountered
whose
value
was
not
a
string
. |
conflicting
indexes
| Multiple conflicting indexes have been found for the same node. |
invalid
@id
value
|
An
@id
member
was
encountered
whose
value
was
not
a
string
. |
invalid
local
context
| In invalid local context was detected. |
loading
remote
context
failed
| There was a problem encountered loading a remote context. |
invalid
remote
context
| No valid context document has been found for a referenced, remote context. |
recursive
context
inclusion
| A cycle in remote context inclusions has been detected. |
invalid
base
IRI
| An invalid base IRI has been detected, i.e., it is neither an absolute IRI nor null . |
invalid
vocab
mapping
| An invalid vocabulary mapping has been detected, i.e., it is neither an absolute IRI nor null . |
invalid
default
language
| The value of the default language is not a string or null and thus invalid. |
keyword
redefinition
| A keyword redefinition has been detected. |
invalid
term
definition
| An invalid term definition has been detected. |
invalid
reverse
property
| An invalid reverse property definition has been detected. |
invalid
IRI
mapping
| A local context contains a term that has an invalid or missing IRI mapping . |
cyclic
IRI
mapping
| A cycle in IRI mappings has been detected. |
invalid
keyword
alias
| An invalid keyword alias definition has been encountered. |
invalid
type
mapping
|
An
@type
member
in
a
term
definition
was
encountered
whose
value
could
not
be
expanded
to
an
absolute
IRI
. |
invalid
language
mapping
|
An
@language
member
in
a
term
definition
was
encountered
whose
value
was
neither
a
string
nor
null
and
thus
invalid.
|
colliding
keywords
| Two properties which expand to the same keyword have been detected. This might occur if a keyword and an an alias thereof are used at the same time. |
invalid
container
mapping
|
An
@container
member
was
encountered
whose
value
was
not
one
of
the
following
strings
:
@list
,
@set
,
or
@index
. |
invalid
type
value
|
An
invalid
value
for
an
@type
member
has
been
detected,
i.e.,
the
value
was
neither
a
string
nor
an
array
of
strings
. |
invalid
value
object
| A value object with disallowed members has been detected. |
invalid
value
object
value
|
An
invalid
value
for
the
@value
member
of
a
value
object
has
been
detected,
i.e.,
it
is
neither
a
scalar
nor
null
. |
invalid
language-tagged
string
| A language-tagged string with an invalid language value was detected. |
invalid
language-tagged
value
| A number , true , or false with an associated language tag was detected. |
invalid
typed
value
| A typed value with an invalid type was detected. |
invalid
set
or
list
object
| A set object or list object with disallowed members has been detected. |
invalid
language
map
value
| An invalid value in a language map has been detected. It has to be a string or an array of strings . |
compaction
to
list
of
lists
| The compacted document contains a list of lists as multiple lists have been compacted to the same term. |
invalid
reverse
property
map
|
An
invalid
reverse
property
map
has
been
detected.
No
keywords
apart
from
@context
are
allowed
in
reverse
property
maps.
|
invalid
@reverse
value
|
An
invalid
value
for
an
@reverse
member
has
been
detected,
i.e.,
the
value
was
not
a
JSON
object
. |
invalid
reverse
property
value
| An invalid value for a reverse property has been detected. The value of an inverse property must be a node object . |
This section is non-normative.
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,
RDFj.
The
work
of
Dave
Lehn
and
Mike
Johnson
who
reviewed,
provided
feedback,
are
appreciated
for
reviewing,
and
performed
performing
several
implementations
of
the
specification,
and
specification.
Ian
Davis,
who
created
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.