Skip to content

Commit 618258b

Browse files
committed
Describe lists containing lists, as motivated by GeoJSON.
Fixes #36.
1 parent 751cd60 commit 618258b

File tree

1 file changed

+137
-6
lines changed

1 file changed

+137
-6
lines changed

index.html

Lines changed: 137 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
prevVersion: "https://www.w3.org/TR/2014/REC-json-ld-20140116/",
2727
previousPublishDate: "2014-01-16",
2828
previousMaturity: "REC",
29+
github: "https://github.com/w3c/json-ld-syntax/",
2930

3031
// if there a publicly available Editor's Draft, this is the link
3132
edDraftURI: "https://w3c.github.io/json-ld/",
3233

3334
includePermalinks: true,
3435
doJsonLd: true,
35-
testSuiteURIkey: "https://json-ld.org/test-suite/",
3636
postProcess: [internalizeTermListReferences],
3737

3838
// if you want to have extra CSS, append them to this list
@@ -95,8 +95,6 @@
9595
note: "v1.0" }
9696
],
9797

98-
github: "https://github.com/w3c/json-ld-syntax/",
99-
10098
// name of the WG
10199
wg: "JSON-LD Working Group",
102100

@@ -2301,9 +2299,141 @@ <h2>Sets and Lists</h2>
23012299
-->
23022300
</pre>
23032301

2304-
<p class="note">List of lists in the form of <a>list objects</a>
2305-
are not allowed in this version of JSON-LD. This decision was made due to the
2306-
extreme amount of added complexity when processing lists of lists.</p>
2302+
<p>The implementation of <a>lists</a> in RDF depends on linking anonymous nodes together using the properties <code>rdf:first</code> and <code>rdf:rest</code>, with the end of the list defined as the resource <code>rdf:nil</code>. This can be represented as triples, as the following example shows, but the results are somewhat unwieldy.</p>
2303+
2304+
<table class="example">
2305+
<thead><tr>
2306+
<th>Subject</th>
2307+
<th>Property</th>
2308+
<th>Value</th>
2309+
</tr></thead>
2310+
<tbody>
2311+
<tr>
2312+
<td>http://example.org/people#joebob</td>
2313+
<td>foaf:nick</td>
2314+
<td>_:b0</td>
2315+
</tr>
2316+
<tr>
2317+
<td>_:b0</td>
2318+
<td>rdf:first</td>
2319+
<td>joe</td>
2320+
</tr>
2321+
<tr>
2322+
<td>_:b0</td>
2323+
<td>rdf:rest</td>
2324+
<td>_:b1</td>
2325+
</tr>
2326+
<tr>
2327+
<td>_:b1</td>
2328+
<td>rdf:first</td>
2329+
<td>bob</td>
2330+
</tr>
2331+
<tr>
2332+
<td>_:b1</td>
2333+
<td>rdf:rest</td>
2334+
<td>_:b2</td>
2335+
</tr>
2336+
<tr>
2337+
<td>_:b2</td>
2338+
<td>rdf:first</td>
2339+
<td>jaybee</td>
2340+
</tr>
2341+
<tr>
2342+
<td>_:b2</td>
2343+
<td>rdf:rest</td>
2344+
<td>rdf:nil</td>
2345+
</tr>
2346+
</tbody>
2347+
</table>
2348+
2349+
<p>Consequently, most RDF serializations (including JSON-LD) provide a syntactic shortcut for these lists. In Turtle, the graph would be expressed as follows:</p>
2350+
2351+
<pre class="example" data-transform="updateExample"
2352+
data-content-type="text/turtle"
2353+
title="An ordered collection of values in Turtle">
2354+
<!--
2355+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
2356+
2357+
<http://example.org/people#joebob> foaf:nick ("joe", "bob", "jaybe") .
2358+
-->
2359+
</pre>
2360+
2361+
<p class="changed">In JSON-LD 1.1, lists of lists, where the value of a <a>list object</a>, may itself be a <a>list object</a> recusively, are fully supported. For example, in <em>GeoJSON</em> (see [[RFC7946]]), <em>coordinates</em> are an ordered list of <em>positions</em>, which are represented as an array of two or more numbers. For example:</p>
2362+
2363+
<pre class="example changed"
2364+
data-content-type="application/json"
2365+
title="Coordinates expressed in GeoJSON">
2366+
{
2367+
"type": "Feature",
2368+
"bbox": [-10.0, -10.0, 10.0, 10.0],
2369+
"geometry": {
2370+
"type": "Polygon",
2371+
"coordinates": [
2372+
[
2373+
[-10.0, -10.0],
2374+
[10.0, -10.0],
2375+
[10.0, 10.0],
2376+
[-10.0, -10.0]
2377+
]
2378+
]
2379+
}
2380+
//...
2381+
}
2382+
</pre>
2383+
2384+
<p class="changed">For this example, it's important that the values expressed within coordinates maintain their order, which requires the use of embedded list structures. In JSON-LD 1.1, we can express this using recursive lists, by simply adding the appropriate context definion:</p>
2385+
2386+
<pre class="example changed"
2387+
data-content-type="application/json"
2388+
data-transform="updateExample"
2389+
title="Coordinates expressed in JSON-LD">
2390+
{
2391+
"@context": {
2392+
"@vocab": "https://purl.org/geojson/vocab#",
2393+
"type": "@type",
2394+
"bbox": {"@container": "@list"},
2395+
"coordinates": {"@container": "@list"}
2396+
},
2397+
"type": "Feature",
2398+
"bbox": [-10.0, -10.0, 10.0, 10.0],
2399+
"geometry": {
2400+
"type": "Polygon",
2401+
"coordinates": [
2402+
[
2403+
[-10.0, -10.0],
2404+
[10.0, -10.0],
2405+
[10.0, 10.0],
2406+
[-10.0, -10.0]
2407+
]
2408+
]
2409+
}
2410+
####//...####
2411+
}
2412+
</pre>
2413+
2414+
<p class="changed">Note that coordinates includes three levels of lists. When expressed in Turtle, this would be the following:</p>
2415+
2416+
<pre class="example changed"
2417+
data-content-type="text/turtle"
2418+
title="Coordinates expressed in Turtle">
2419+
@prefix geojson: <https://purl.org/geojson/vocab#>.
2420+
2421+
[
2422+
a geojson:Feature ;
2423+
geojson:bbox (-10.0 -10.0 10.0 10.0) ;
2424+
geojson:geometry [
2425+
a geojson:Polygon ;
2426+
geojson:coordinates (
2427+
(
2428+
(-10.0 -10.0)
2429+
(10.0 -10.0)
2430+
(10.0 10.0)
2431+
(-10.0 -10.0)
2432+
)
2433+
)
2434+
]
2435+
] .
2436+
</pre>
23072437

23082438
<p>While <code>@list</code> is used to describe <em>ordered lists</em>,
23092439
the <code>@set</code> keyword is used to describe <em>unordered sets</em>.
@@ -5118,6 +5248,7 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
51185248
a context. When this is set, vocabulary-relative IRIs, such as the
51195249
keys of <a>node objects</a>, are expanded or compacted relative
51205250
to the <a>base IRI</a> using string concatenation.</li>
5251+
<li><a>Lists</a> may now have members which are themselves <a>lists</a>.</li>
51215252
</ul>
51225253
</section>
51235254

0 commit comments

Comments
 (0)