|
26 | 26 | prevVersion: "https://www.w3.org/TR/2014/REC-json-ld-20140116/",
|
27 | 27 | previousPublishDate: "2014-01-16",
|
28 | 28 | previousMaturity: "REC",
|
| 29 | + github: "https://github.com/w3c/json-ld-syntax/", |
29 | 30 |
|
30 | 31 | // if there a publicly available Editor's Draft, this is the link
|
31 | 32 | edDraftURI: "https://w3c.github.io/json-ld-syntax/",
|
32 | 33 |
|
33 | 34 | includePermalinks: true,
|
34 | 35 | doJsonLd: true,
|
35 |
| - testSuiteURIkey: "https://json-ld.org/test-suite/", |
36 | 36 | postProcess: [internalizeTermListReferences],
|
37 | 37 |
|
38 | 38 | // if you want to have extra CSS, append them to this list
|
|
95 | 95 | note: "v1.0" }
|
96 | 96 | ],
|
97 | 97 |
|
98 |
| - github: "https://github.com/w3c/json-ld-syntax/", |
99 |
| - |
100 | 98 | // name of the WG
|
101 | 99 | wg: "JSON-LD Working Group",
|
102 | 100 |
|
@@ -2333,9 +2331,141 @@ <h2>Sets and Lists</h2>
|
2333 | 2331 | -->
|
2334 | 2332 | </pre>
|
2335 | 2333 |
|
2336 |
| -<p class="note">List of lists in the form of <a>list objects</a> |
2337 |
| - are not allowed in this version of JSON-LD. This decision was made due to the |
2338 |
| - extreme amount of added complexity when processing lists of lists.</p> |
| 2334 | +<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> |
| 2335 | + |
| 2336 | +<table class="example"> |
| 2337 | +<thead><tr> |
| 2338 | + <th>Subject</th> |
| 2339 | + <th>Property</th> |
| 2340 | + <th>Value</th> |
| 2341 | +</tr></thead> |
| 2342 | +<tbody> |
| 2343 | +<tr> |
| 2344 | + <td>http://example.org/people#joebob</td> |
| 2345 | + <td>foaf:nick</td> |
| 2346 | + <td>_:b0</td> |
| 2347 | +</tr> |
| 2348 | +<tr> |
| 2349 | + <td>_:b0</td> |
| 2350 | + <td>rdf:first</td> |
| 2351 | + <td>joe</td> |
| 2352 | +</tr> |
| 2353 | +<tr> |
| 2354 | + <td>_:b0</td> |
| 2355 | + <td>rdf:rest</td> |
| 2356 | + <td>_:b1</td> |
| 2357 | +</tr> |
| 2358 | +<tr> |
| 2359 | + <td>_:b1</td> |
| 2360 | + <td>rdf:first</td> |
| 2361 | + <td>bob</td> |
| 2362 | +</tr> |
| 2363 | +<tr> |
| 2364 | + <td>_:b1</td> |
| 2365 | + <td>rdf:rest</td> |
| 2366 | + <td>_:b2</td> |
| 2367 | +</tr> |
| 2368 | +<tr> |
| 2369 | + <td>_:b2</td> |
| 2370 | + <td>rdf:first</td> |
| 2371 | + <td>jaybee</td> |
| 2372 | +</tr> |
| 2373 | +<tr> |
| 2374 | + <td>_:b2</td> |
| 2375 | + <td>rdf:rest</td> |
| 2376 | + <td>rdf:nil</td> |
| 2377 | +</tr> |
| 2378 | +</tbody> |
| 2379 | +</table> |
| 2380 | + |
| 2381 | +<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> |
| 2382 | + |
| 2383 | +<pre class="example" data-transform="updateExample" |
| 2384 | + data-content-type="text/turtle" |
| 2385 | + title="An ordered collection of values in Turtle"> |
| 2386 | +<!-- |
| 2387 | +@prefix foaf: <http://xmlns.com/foaf/0.1/> . |
| 2388 | +
|
| 2389 | +<http://example.org/people#joebob> foaf:nick ("joe", "bob", "jaybe") . |
| 2390 | +--> |
| 2391 | +</pre> |
| 2392 | + |
| 2393 | +<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> |
| 2394 | + |
| 2395 | +<pre class="example changed" |
| 2396 | + data-content-type="application/json" |
| 2397 | + title="Coordinates expressed in GeoJSON"> |
| 2398 | +{ |
| 2399 | + "type": "Feature", |
| 2400 | + "bbox": [-10.0, -10.0, 10.0, 10.0], |
| 2401 | + "geometry": { |
| 2402 | + "type": "Polygon", |
| 2403 | + "coordinates": [ |
| 2404 | + [ |
| 2405 | + [-10.0, -10.0], |
| 2406 | + [10.0, -10.0], |
| 2407 | + [10.0, 10.0], |
| 2408 | + [-10.0, -10.0] |
| 2409 | + ] |
| 2410 | + ] |
| 2411 | + } |
| 2412 | + //... |
| 2413 | +} |
| 2414 | +</pre> |
| 2415 | + |
| 2416 | +<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> |
| 2417 | + |
| 2418 | +<pre class="example changed" |
| 2419 | + data-content-type="application/json" |
| 2420 | + data-transform="updateExample" |
| 2421 | + title="Coordinates expressed in JSON-LD"> |
| 2422 | +{ |
| 2423 | + "@context": { |
| 2424 | + "@vocab": "https://purl.org/geojson/vocab#", |
| 2425 | + "type": "@type", |
| 2426 | + "bbox": {"@container": "@list"}, |
| 2427 | + "coordinates": {"@container": "@list"} |
| 2428 | + }, |
| 2429 | + "type": "Feature", |
| 2430 | + "bbox": [-10.0, -10.0, 10.0, 10.0], |
| 2431 | + "geometry": { |
| 2432 | + "type": "Polygon", |
| 2433 | + "coordinates": [ |
| 2434 | + [ |
| 2435 | + [-10.0, -10.0], |
| 2436 | + [10.0, -10.0], |
| 2437 | + [10.0, 10.0], |
| 2438 | + [-10.0, -10.0] |
| 2439 | + ] |
| 2440 | + ] |
| 2441 | + } |
| 2442 | + ####//...#### |
| 2443 | +} |
| 2444 | +</pre> |
| 2445 | + |
| 2446 | +<p class="changed">Note that coordinates includes three levels of lists. When expressed in Turtle, this would be the following:</p> |
| 2447 | + |
| 2448 | +<pre class="example changed" |
| 2449 | + data-content-type="text/turtle" |
| 2450 | + title="Coordinates expressed in Turtle"> |
| 2451 | +@prefix geojson: <https://purl.org/geojson/vocab#>. |
| 2452 | + |
| 2453 | +[ |
| 2454 | + a geojson:Feature ; |
| 2455 | + geojson:bbox (-10.0 -10.0 10.0 10.0) ; |
| 2456 | + geojson:geometry [ |
| 2457 | + a geojson:Polygon ; |
| 2458 | + geojson:coordinates ( |
| 2459 | + ( |
| 2460 | + (-10.0 -10.0) |
| 2461 | + (10.0 -10.0) |
| 2462 | + (10.0 10.0) |
| 2463 | + (-10.0 -10.0) |
| 2464 | + ) |
| 2465 | + ) |
| 2466 | + ] |
| 2467 | +] . |
| 2468 | +</pre> |
2339 | 2469 |
|
2340 | 2470 | <p>While <code>@list</code> is used to describe <em>ordered lists</em>,
|
2341 | 2471 | the <code>@set</code> keyword is used to describe <em>unordered sets</em>.
|
@@ -5158,6 +5288,7 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
|
5158 | 5288 | a context. When this is set, vocabulary-relative IRIs, such as the
|
5159 | 5289 | keys of <a>node objects</a>, are expanded or compacted relative
|
5160 | 5290 | to the <a>base IRI</a> using string concatenation.</li>
|
| 5291 | + <li><a>Lists</a> may now have members which are themselves <a>lists</a>.</li> |
5161 | 5292 | </ul>
|
5162 | 5293 | </section>
|
5163 | 5294 |
|
|
0 commit comments