You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+80Lines changed: 80 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -298,6 +298,86 @@ The value of `@container` in a term definition can include `@id` or `@type`, in
298
298
}
299
299
}
300
300
301
+
### @graph containers and maps
302
+
A term can have `@container` set to include `@graph` optionally including `@id` or `@index` and `@set`. In the first form, with `@container` set to `@graph`, the value of a property is treated as a _simple graph object_, meaning that values treated as if they were contained in an object with `@graph`, creating _named graph_ with an anonymous name.
303
+
304
+
{
305
+
"@context": {
306
+
"@vocab": "http://example.org/",
307
+
"input": {"@container": "@graph"}
308
+
},
309
+
"input": {
310
+
"value": "x"
311
+
}
312
+
}
313
+
314
+
which expands to the following:
315
+
316
+
[{
317
+
"http://example.org/input": [{
318
+
"@graph": [{
319
+
"http://example.org/value": [{"@value": "x"}]
320
+
}]
321
+
}]
322
+
}]
323
+
324
+
Compaction reverses this process, optionally ensuring that a single value is contained within an array of `@container` also includes `@set`:
325
+
326
+
{
327
+
"@context": {
328
+
"@vocab": "http://example.org/",
329
+
"input": {"@container": ["@graph", "@set"]}
330
+
}
331
+
}
332
+
333
+
A graph map uses the map form already existing for `@index`, `@language`, `@type`, and `@id` where the index is either an index value or an id.
334
+
335
+
{
336
+
"@context": {
337
+
"@vocab": "http://example.org/",
338
+
"input": {"@container": ["@graph", "@index"]}
339
+
},
340
+
"input": {
341
+
"g1": {"value": "x"}
342
+
}
343
+
}
344
+
345
+
treats "g1" as an index, and expands to the following:
346
+
347
+
[{
348
+
"http://example.org/input": [{
349
+
"@index": "g1",
350
+
"@graph": [{
351
+
"http://example.org/value": [{"@value": "x"}]
352
+
}]
353
+
}]
354
+
}])
355
+
356
+
This can also include `@set` to ensure that, when compacting, a single value of an index will be in array form.
357
+
358
+
The _id_ version is similar:
359
+
360
+
{
361
+
"@context": {
362
+
"@vocab": "http://example.org/",
363
+
"input": {"@container": ["@graph", "@id"]}
364
+
},
365
+
"input": {
366
+
"http://example.com/g1": {"value": "x"}
367
+
}
368
+
}
369
+
370
+
which expands to:
371
+
372
+
[{
373
+
"http://example.org/input": [{
374
+
"@id": "http://example.com/g1",
375
+
"@graph": [{
376
+
"http://example.org/value": [{"@value": "x"}]
377
+
}]
378
+
}]
379
+
}])
380
+
301
381
### Transparent Nesting
302
382
Many JSON APIs separate properties from their entities using an intermediate object. For example, a set of possible labels may be grouped under a common property:
0 commit comments