From 3f035c775d1085618a43204b4cd8e25800bd4d31 Mon Sep 17 00:00:00 2001
From: Gregg Kellogg Many JSON APIs separate properties from their entities using an
+ intermediate object; in JSON-LD these are called nested properties.
+ For example, a set of possible labels may be grouped
+ under a common property: By defining labels using the keyword Similarly, node definitions may contain a General Terminology
specified via the @context
keyword.
Algorithm
@reverse
:
-
@id
, member, an
+ @id
or @nest
, members, an
invalid reverse property
error has been detected and processing is aborted.@reverse
key
@@ -1019,9 +1019,18 @@ Algorithm
of definition to language.@nest
:
+
+
+ @nest
key, which must be a string and
+ must not be a keyword other than @nest
. Otherwise, an
+ invalid @nest value
+ error has been detected and processing is aborted.@id
,
@reverse
, @container
,
- @context
, or @type
, an
+ @context
, @nest
, or @type
, an
invalid term definition error has
been detected and processing is aborted.Algorithm
passing active context and the value of the
@context
key as local context.
@context
, continue to
@@ -1417,6 +1426,10 @@ Algorithm
@nest
,
+ add key to nests, initializing it to an empty array,
+ if necessary.
+ Continue with the next key from element.frame expansion
flag is set,
if expanded property is any other
framing keyword (@explicit
, @default
,
@@ -1545,6 +1558,22 @@ Algorithm
member of result.
+
+
+
+ @value
, an
+ invalid @nest value error
+ has been detected and processing is aborted.@value
:
@@ -1928,7 +1957,22 @@ Algorithm
expanded value for value,
true
for vocab, and
inside reverse.@nest
+ member, that value (nest term) must be
+ @nest
, or a term definition in the
+ active context that expands to @nest
,
+ otherwise an invalid @nest
+ value error has been detected, and processing is aborted.
+ If result does not have the key that equals nest
+ term, initialize it to an empty JSON object (nest
+ object). If nest object does not have the key
+ that equals item active property, set this key's
+ value in nest object to an empty
+ array.Otherwise, if the key's value is not an
+ array, then set it to one containing only the
+ value.Algorithm
expanded item for value,
true
for vocab, and
inside reverse.@nest
+ member, that value (nest term) must be
+ @nest
, or a term definition in the
+ active context that expands to @nest
,
+ otherwise an invalid @nest
+ value error has been detected, and processing is aborted.
+ Set nest result to the value of nest term in result,
+ initializing it to a new JSON object, if necessary; otherwise
+ set nest result to result.null
. If there
is a container mapping for
item active property in active context,
@@ -1985,7 +2039,7 @@ Algorithm
Algorithm
@index
:
@language
and
compacted item contains the key
@value
, then set compacted item
@@ -2030,9 +2084,9 @@ Algorithm
JsonLdErrorCode
"invalid language mapping",
"invalid language-tagged string",
"invalid language-tagged value",
+ "invalid @nest value",
"invalid local context",
"invalid remote context",
"invalid reverse property",
@@ -4134,6 +4189,8 @@ JsonLdErrorCode
associated language tag was detected.@nest
has been found.Changes since 1.0 Recommendation of 16 January 2014
@nest
property, which identifies a term expanding to
+ @nest
which is used for containing properties using the same
+ @nest
mapping. When expanding, the values of a property
+ expanding to @nest
are treated as if they were contained
+ within the enclosing node object directly.Syntax Tokens and Keywords
IRI. This keyword is described in .
@graph
@nest
:
Data Indexing
+Nested Properties
+
+
+
+
+
+ @nest
,
+ a JSON-LD processor will ignore the nesting created by using the
+ labels property and process the contents as if it were declared
+ directly within containing object. In this case, the labels
+ property is semantically meaningless. Defining it as equivalent to
+ @nest
causes it to be ignored when expanding, making it
+ equivalent to the following:
+
+
+
+ @nest
property to
+ reference a term aliased to @nest
which causes such
+ values to be nested under that aliased term.
+
+
+Expanded Document Form
@@ -2989,6 +3070,7 @@ Node Objects
@context
,@id
,@graph
,@nest
,@type
,@reverse
, or@index
Node Objects
for further discussion
on @index
values.
If the node object contains the @nest
key,
+ its value MUST be an JSON object or an array of JSON objects
+ which MUST NOT include a value object. See
+ for further discussion
+ on @nest
values.
Keys in a node object that are not keyword MAY expand to an absolute IRI using the active context. The values associated with keys that expand @@ -3186,6 +3274,19 @@
See for further information on this topic.
+A nested property is used to gather properties of a node object in a separate + JSON object, or array of JSON objects which are not + value objects. It is semantically transparent and is removed + during the process of expansion. Property nesting is recursive, and + collections of nested properties may contain further nesting.
+ +Semantically, nesting is treated as if the properties and values were declared directly + within the containing node object.
+If an expanded term definition has an @reverse
member,
- it MUST NOT have an @id
member at the same time. If an
+ it MUST NOT have @id
or @nest
members at the same time. If an
@container
member exists, its value MUST be null,
@set
, or @index
.
If the expanded term definition contains the @nest
+ keyword, its value MUST be either @nest
, or a term
+ which expands to @nest
.
@context
property, which defines a context used for values of
a property identified with such a term.@nest
property, which identifies a term expanding to
+ @nest
which is used for containing properties using the same
+ @nest
mapping. When expanding, the values of a property
+ expanding to @nest
are treated as if they were contained
+ within the enclosing node object directly.The following is a list of open issues being worked on for the next release.
- - - diff --git a/test-suite/tests/compact-manifest.jsonld b/test-suite/tests/compact-manifest.jsonld index 3958cad83..2ef140639 100644 --- a/test-suite/tests/compact-manifest.jsonld +++ b/test-suite/tests/compact-manifest.jsonld @@ -630,6 +630,96 @@ "context": "compact-c005-context.jsonld", "expect": "compact-c005-out.jsonld", "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn001", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Indexes to @nest for property with @nest", + "purpose": "Compaction using @nest", + "input": "compact-n001-in.jsonld", + "context": "compact-n001-context.jsonld", + "expect": "compact-n001-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn002", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Indexes to @nest for all properties with @nest", + "purpose": "Compaction using @nest", + "input": "compact-n002-in.jsonld", + "context": "compact-n002-context.jsonld", + "expect": "compact-n002-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn003", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nests using alias of @nest", + "purpose": "Compaction using @nest", + "input": "compact-n003-in.jsonld", + "context": "compact-n003-context.jsonld", + "expect": "compact-n003-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn004", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Arrays of nested values", + "purpose": "Compaction using @nest", + "input": "compact-n004-in.jsonld", + "context": "compact-n004-context.jsonld", + "expect": "compact-n004-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn005", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nested @container: @list", + "purpose": "Compaction using @nest", + "input": "compact-n005-in.jsonld", + "context": "compact-n005-context.jsonld", + "expect": "compact-n005-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn006", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nested @container: @index", + "purpose": "Compaction using @nest", + "input": "compact-n006-in.jsonld", + "context": "compact-n006-context.jsonld", + "expect": "compact-n006-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn007", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nested @container: @language", + "purpose": "Compaction using @nest", + "input": "compact-n007-in.jsonld", + "context": "compact-n007-context.jsonld", + "expect": "compact-n007-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn008", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nested @container: @type", + "purpose": "Compaction using @nest", + "input": "compact-n008-in.jsonld", + "context": "compact-n008-context.jsonld", + "expect": "compact-n008-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn009", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Nested @container: @id", + "purpose": "Compaction using @nest", + "input": "compact-n009-in.jsonld", + "context": "compact-n009-context.jsonld", + "expect": "compact-n009-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tn010", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Multiple nest aliases", + "purpose": "Compaction using @nest", + "input": "compact-n010-in.jsonld", + "context": "compact-n010-context.jsonld", + "expect": "compact-n010-out.jsonld", + "option": {"processingMode": "json-ld-1.1"} } ] } diff --git a/test-suite/tests/compact-n001-context.jsonld b/test-suite/tests/compact-n001-context.jsonld new file mode 100644 index 000000000..18017f10b --- /dev/null +++ b/test-suite/tests/compact-n001-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p2": {"@nest": "@nest"} + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n001-in.jsonld b/test-suite/tests/compact-n001-in.jsonld new file mode 100644 index 000000000..c03734564 --- /dev/null +++ b/test-suite/tests/compact-n001-in.jsonld @@ -0,0 +1,4 @@ +[{ + "http://example.org/p1": [{"@value": "v1"}], + "http://example.org/p2": [{"@value": "v2"}] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n001-out.jsonld b/test-suite/tests/compact-n001-out.jsonld new file mode 100644 index 000000000..15819870e --- /dev/null +++ b/test-suite/tests/compact-n001-out.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p2": {"@nest": "@nest"} + }, + "p1": "v1", + "@nest": { + "p2": "v2" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n002-context.jsonld b/test-suite/tests/compact-n002-context.jsonld new file mode 100644 index 000000000..557c93ac2 --- /dev/null +++ b/test-suite/tests/compact-n002-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p1": {"@nest": "@nest"}, + "p2": {"@nest": "@nest"} + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n002-in.jsonld b/test-suite/tests/compact-n002-in.jsonld new file mode 100644 index 000000000..c03734564 --- /dev/null +++ b/test-suite/tests/compact-n002-in.jsonld @@ -0,0 +1,4 @@ +[{ + "http://example.org/p1": [{"@value": "v1"}], + "http://example.org/p2": [{"@value": "v2"}] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n002-out.jsonld b/test-suite/tests/compact-n002-out.jsonld new file mode 100644 index 000000000..e9ff8d7c1 --- /dev/null +++ b/test-suite/tests/compact-n002-out.jsonld @@ -0,0 +1,11 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p1": {"@nest": "@nest"}, + "p2": {"@nest": "@nest"} + }, + "@nest": { + "p1": "v1", + "p2": "v2" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n003-context.jsonld b/test-suite/tests/compact-n003-context.jsonld new file mode 100644 index 000000000..421621b30 --- /dev/null +++ b/test-suite/tests/compact-n003-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "nest": "@nest", + "p2": {"@nest": "nest"} + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n003-in.jsonld b/test-suite/tests/compact-n003-in.jsonld new file mode 100644 index 000000000..c03734564 --- /dev/null +++ b/test-suite/tests/compact-n003-in.jsonld @@ -0,0 +1,4 @@ +[{ + "http://example.org/p1": [{"@value": "v1"}], + "http://example.org/p2": [{"@value": "v2"}] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n003-out.jsonld b/test-suite/tests/compact-n003-out.jsonld new file mode 100644 index 000000000..a2415a83c --- /dev/null +++ b/test-suite/tests/compact-n003-out.jsonld @@ -0,0 +1,11 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "nest": "@nest", + "p2": {"@nest": "nest"} + }, + "p1": "v1", + "nest": { + "p2": "v2" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n004-context.jsonld b/test-suite/tests/compact-n004-context.jsonld new file mode 100644 index 000000000..18017f10b --- /dev/null +++ b/test-suite/tests/compact-n004-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p2": {"@nest": "@nest"} + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n004-in.jsonld b/test-suite/tests/compact-n004-in.jsonld new file mode 100644 index 000000000..5b70771a3 --- /dev/null +++ b/test-suite/tests/compact-n004-in.jsonld @@ -0,0 +1,4 @@ +[{ + "http://example.org/p1": [{"@value": "v1"}], + "http://example.org/p2": [{"@value": "v2"}, {"@value": "v3"}] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n004-out.jsonld b/test-suite/tests/compact-n004-out.jsonld new file mode 100644 index 000000000..66705e9b9 --- /dev/null +++ b/test-suite/tests/compact-n004-out.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "p2": {"@nest": "@nest"} + }, + "p1": "v1", + "@nest": { + "p2": ["v2", "v3"] + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n005-context.jsonld b/test-suite/tests/compact-n005-context.jsonld new file mode 100644 index 000000000..5a712da14 --- /dev/null +++ b/test-suite/tests/compact-n005-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "list": {"@container": "@list", "@nest": "nestedlist"}, + "nestedlist": "@nest" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n005-in.jsonld b/test-suite/tests/compact-n005-in.jsonld new file mode 100644 index 000000000..ad985e83f --- /dev/null +++ b/test-suite/tests/compact-n005-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example.org/list": [{"@list": [ + {"@value": "a"}, + {"@value": "b"} + ]}] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n005-out.jsonld b/test-suite/tests/compact-n005-out.jsonld new file mode 100644 index 000000000..5e0035ab3 --- /dev/null +++ b/test-suite/tests/compact-n005-out.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "list": {"@container": "@list", "@nest": "nestedlist"}, + "nestedlist": "@nest" + }, + "nestedlist": { + "list": ["a", "b"] + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n006-context.jsonld b/test-suite/tests/compact-n006-context.jsonld new file mode 100644 index 000000000..281100fc7 --- /dev/null +++ b/test-suite/tests/compact-n006-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "index": {"@container": "@index", "@nest": "nestedindex"}, + "nestedindex": "@nest" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n006-in.jsonld b/test-suite/tests/compact-n006-in.jsonld new file mode 100644 index 000000000..2682faf32 --- /dev/null +++ b/test-suite/tests/compact-n006-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example.org/index": [ + {"@value": "a", "@index": "A"}, + {"@value": "b", "@index": "B"} + ] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n006-out.jsonld b/test-suite/tests/compact-n006-out.jsonld new file mode 100644 index 000000000..49f2172da --- /dev/null +++ b/test-suite/tests/compact-n006-out.jsonld @@ -0,0 +1,13 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "index": {"@container": "@index", "@nest": "nestedindex"}, + "nestedindex": "@nest" + }, + "nestedindex": { + "index": { + "A": "a", + "B": "b" + } + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n007-context.jsonld b/test-suite/tests/compact-n007-context.jsonld new file mode 100644 index 000000000..02492cee3 --- /dev/null +++ b/test-suite/tests/compact-n007-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "container": {"@container": "@language", "@nest": "nestedlanguage"}, + "nestedlanguage": "@nest" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n007-in.jsonld b/test-suite/tests/compact-n007-in.jsonld new file mode 100644 index 000000000..f32329ab1 --- /dev/null +++ b/test-suite/tests/compact-n007-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example.org/container": [ + {"@value": "Die Königin", "@language": "de"}, + {"@value": "The Queen", "@language": "en"} + ] +}] \ No newline at end of file diff --git a/test-suite/tests/compact-n007-out.jsonld b/test-suite/tests/compact-n007-out.jsonld new file mode 100644 index 000000000..659788d4c --- /dev/null +++ b/test-suite/tests/compact-n007-out.jsonld @@ -0,0 +1,13 @@ +{ + "@context": { + "@vocab": "http://example.org/", + "container": {"@container": "@language", "@nest": "nestedlanguage"}, + "nestedlanguage": "@nest" + }, + "nestedlanguage": { + "container": { + "en": "The Queen", + "de": "Die Königin" + } + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n008-context.jsonld b/test-suite/tests/compact-n008-context.jsonld new file mode 100644 index 000000000..0eeff3163 --- /dev/null +++ b/test-suite/tests/compact-n008-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example/", + "typemap": {"@container": "@type", "@nest": "nestedtypemap"}, + "nestedtypemap": "@nest" + } +} \ No newline at end of file diff --git a/test-suite/tests/compact-n008-in.jsonld b/test-suite/tests/compact-n008-in.jsonld new file mode 100644 index 000000000..ecdfc4498 --- /dev/null +++ b/test-suite/tests/compact-n008-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example/typemap": [ + {"http://example/label": [{"@value": "Object with @type _:bar"}], "@type": ["_:bar"]}, + {"http://example/label": [{"@value": "Object with @type@index
member was encountered whose value was
not a string.@nest
has been found.@reverse
member has been detected,
i.e., the value was not a JSON object.@nest
has been found.