forked from w3c/json-ld-syntax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
9982 lines (9264 loc) · 392 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>JSON-LD 1.1</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="https://www.w3.org/Tools/respec/respec-w3c-common" class="remove" defer></script>
<script type="text/javascript" src="common/common.js" class="remove" defer></script>
<script type="text/javascript" src="common/jsonld.js" class="remove"></script>
<script type="text/javascript" class="remove">
//<![CDATA[
var respecConfig = {
// extend the bibliography entries
localBiblio: jsonld.localBiblio,
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
// if you wish the publication date to be other than today, set this
//publishDate: "2018-09-11",
copyrightStart: "2010",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "json-ld11",
subtitle: "A JSON-based Serialization for Linked Data",
// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
// and its maturity status
prevVersion: "https://www.w3.org/TR/2018/WD-json-ld11-20180911/",
previousPublishDate: "2018-09-11",
previousMaturity: "FPWD",
github: "https://github.com/w3c/json-ld-syntax/",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/json-ld-syntax/",
includePermalinks: true,
doJsonLd: true,
// if you want to have extra CSS, append them to this list
// it is recommended that the respec.css stylesheet be kept
// extraCSS: [],
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Gregg Kellogg",
url: "http://greggkellogg.net/",
company: "Spec-Ops",
companyURL: "https://spec-ops.io/",
w3cid: "44770",
note: "v1.0 and v1.1" }
],
// editors, add as many as you like
// only "name" is required
formerEditors: [
{ name: "Manu Sporny",
url: "http://manu.sporny.org/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Markus Lanthaler",
url: "http://www.markus-lanthaler.com/",
company: "Graz University of Technology",
companyURL: "http://www.tugraz.at/",
note: "v1.0" }
],
// authors, add as many as you like.
// This is optional, uncomment if you have authors as well as editors.
// only "name" is required. Same format as editors.
authors: [
{ name: "Manu Sporny",
url: "http://manu.sporny.org/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Dave Longley",
url: "https://digitalbazaar.com/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Gregg Kellogg",
url: "http://greggkellogg.net/",
company: "Spec-Ops",
companyURL: "https://spec-ops.io/",
w3cid: "44770",
note: "v1.0 and v1.1" },
{ name: "Markus Lanthaler",
url: "http://www.markus-lanthaler.com/",
company: "Graz University of Technology",
companyURL: "http://www.tugraz.at/",
note: "v1.0" },
{ name: "Niklas Lindström",
url: "http://neverspace.net/",
note: "v1.0" }
],
// name of the WG
wg: "JSON-LD Working Group",
// URI of the public WG page
wgURI: "https://www.w3.org/2018/json-ld-wg/",
// name (with the @w3c.org) of the public mailing to which comments are due
wgPublicList: "public-json-ld-wg",
// URI of the patent status for this WG, for Rec-track documents
// !!!! IMPORTANT !!!!
// This is important for Rec-track documents, do not copy a patent URI from a random
// document unless you know what you're doing. If in doubt ask your friendly neighbourhood
// Team Contact.
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/107714/status",
processVersion: 2018,
maxTocLevel: 4
///alternateFormats: [ {uri: "diff-20140116.html", label: "diff to previous version"} ]
};
//]]>
</script>
<script type="text/javascript">
// Add example button selection logic
document.addEventListener("DOMContentLoaded", () => {
for (const button of document.querySelectorAll(".ds-selector-tabs .selectors button")) {
button.onclick = () => {
const ex = button.closest(".ds-selector-tabs");
ex.querySelector("button.selected").classList.remove("selected");
ex.querySelector(".selected").classList.remove("selected");
button.classList.add('selected');
ex.querySelector("." + button.dataset.selects).classList.add("selected");
}
}
})
</script>
<style type="text/css">
.hl-bold { font-weight: bold; color: #0a3; }
.comment { color: #999; }
table, thead, tr, td { padding: 5px; border-width: 1px; border-spacing: 0px; border-style: solid; border-collapse: collapse; }
table.example {width: 100%;}
.hl-bold {
font-weight: bold;
color: #0a3;
}
.comment {
color: #999;
}
.changed {
background-color: rgb(215, 238, 197);
}
.changed:hover {
color: green;
background-color: inherit;
}
aside.example {
overflow-y: hidden;
}
/* example tab selection */
.ds-selector-tabs {
padding-bottom: 2em;
}
.ds-selector-tabs .selectors {
padding: 0;
border-bottom: 1px solid #ccc;
height: 28px;
}
.ds-selector-tabs .selectors button {
display: inline-block;
min-width: 54px;
text-align: center;
font-size: 11px;
font-weight: bold;
height: 27px;
padding: 0 8px;
line-height: 27px;
transition: all,0.218s;
border-top-right-radius: 2px;
border-top-left-radius: 2px;
color: #666;
border: 1px solid transparent;
}
.ds-selector-tabs .selectors button:first-child {
margin-left: 2px;
}
.ds-selector-tabs .selectors button.selected {
color: #202020 !important;
border: 1px solid #ccc;
border-bottom: 1px solid #fff !important;
}
.ds-selector-tabs .selectors button:hover {
background-color: transparent;
color: #202020;
cursor: pointer;
}
.ds-selector-tabs pre, .ds-selector-tabs table {
display: none;
}
.ds-selector-tabs pre.selected, .ds-selector-tabs table.selected {
display: block;
}
button.playground {
width: 150px;
}
a.playground {
border-bottom: none;
text-decoration: none;
font-size: 13px;
}
a[href].playground {
border-bottom: none;
text-decoration: none;
color: #666;
}
</style>
</head>
<body>
<section id="abstract">
<p>JSON is a useful data serialization and messaging format.
This specification defines JSON-LD, a JSON-based format to serialize
Linked Data. The syntax is designed to easily integrate into deployed
systems that already use JSON, and provides a smooth upgrade path from
JSON to JSON-LD.
It is primarily intended to be a way to use Linked Data in Web-based
programming environments, to build interoperable Web services, and to
store Linked Data in JSON-based storage engines.</p>
</section>
<section id="sotd">
<p>This document has been developed by the
<a href="https://www.w3.org/2018/json-ld-wg/">JSON-LD Working Group</a> and was derived from the <a href="https://www.w3.org/community/json-ld/">JSON-LD Community Group's</a> <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/">Final Report</a>.</p>
<p>There is a
<a href="https://json-ld.org/playground-dev/">live JSON-LD playground</a> that is capable
of demonstrating the features described in this document.</p>
<section>
<h2>Set of Documents</h2>
<p>This document is one of three JSON-LD 1.1 Recommendations produced by the
<a href="https://www.w3.org/2018/json-ld-wg/">JSON-LD Working Group</a>:</p>
<ul>
<li><a data-cite="JSON-LD11">JSON-LD 1.1</a></li>
<li><a data-cite="JSON-LD11-API">JSON-LD 1.1 Processing Algorithms and API</a></li>
<li><a data-cite="JSON-LD11-FRAMING">JSON-LD 1.1 Framing</a></li>
</ul>
</section>
</section>
<section class="informative">
<h1>Introduction</h1>
<p>Linked Data [[LINKED-DATA]] is a way to create a network of
standards-based machine interpretable data across different documents and
Web sites. It allows an application to start at one piece of Linked Data,
and follow embedded links to other pieces of Linked Data that are hosted on
different sites across the Web.</p>
<p>JSON-LD is a lightweight syntax to serialize Linked Data in
JSON [[!RFC8259]]. Its design allows existing JSON to be interpreted as
Linked Data with minimal changes. JSON-LD is primarily intended to be a
way to use Linked Data in Web-based programming environments, to build
interoperable Web services, and to store Linked Data in JSON-based storage engines. Since
JSON-LD is 100% compatible with JSON, the large number of JSON parsers and libraries
available today can be reused. In addition to all the features JSON provides,
JSON-LD introduces:</p>
<ul>
<li>a universal identifier mechanism for <a>JSON objects</a>
via the use of <a>IRIs</a>,</li>
<li>a way to disambiguate keys shared among different JSON documents by mapping
them to <a>IRIs</a> via a <a>context</a>,</li>
<li>a mechanism in which a value in a <a>JSON object</a> may refer
to a <a>resource</a> on a different site on the Web,</li>
<li>the ability to annotate <a>strings</a> with their language,</li>
<li>a way to associate datatypes with values such as dates and times,</li>
<li>and a facility to express one or more directed graphs, such as a social
network, in a single document.</li>
</ul>
<p>
JSON-LD is designed to be usable directly as JSON, with no knowledge of RDF
[[RDF11-CONCEPTS]]. It is also designed to be usable as RDF, if desired, for
use with other Linked Data technologies like SPARQL. Developers who
require any of the facilities listed above or need to serialize an RDF <a>Graph</a>
or <a>Dataset</a> in a JSON-based syntax will find JSON-LD of interest. People
intending to use JSON-LD with RDF tools will find it can be used as another
RDF syntax, as with [[Turtle]] and [[TriG]]. Complete details of how JSON-LD relates
to RDF are in section <a href="#relationship-to-rdf"></a>.
</p>
<p>
The syntax is designed to not disturb already
deployed systems running on JSON, but provide a smooth upgrade path from
JSON to JSON-LD. Since the shape of such data varies wildly, JSON-LD
features mechanisms to reshape documents into a deterministic structure
which simplifies their processing.</p>
<section class="informative">
<h2>How to Read this Document</h2>
<p>This document is a detailed specification for a serialization of Linked
Data in JSON. The document is primarily intended for the following audiences:</p>
<ul>
<li>Software developers who want to encode Linked Data in a variety of
programming languages that can use JSON</li>
<li>Software developers who want to convert existing JSON to JSON-LD</li>
<li>Software developers who want to understand the design decisions and
language syntax for JSON-LD</li>
<li>Software developers who want to implement processors and APIs for
JSON-LD</li>
<li>Software developers who want to generate or consume Linked Data,
an RDF <a>graph</a>, or an <a>RDF Dataset</a> in a JSON syntax</li>
</ul>
<p>A companion document, the JSON-LD 1.1 Processing Algorithms and API specification
[[JSON-LD11-API]], specifies how to work with JSON-LD at a higher level by
providing a standard library interface for common JSON-LD operations.</p>
<p>To understand the basics in this specification you must first be familiar with
<a data-cite="RFC8259">JSON</a>, which is detailed in [[!RFC8259]].</p>
<p>This document almost exclusively uses the term IRI
(<a data-cite="ld-glossary#internationalized-resource-identifier">Internationalized Resource Indicator</a>)
when discussing hyperlinks. Many Web developers are more familiar with the
URL (<a data-cite="ld-glossary#uniform-resource-locator">Uniform Resource Locator</a>)
terminology. The document also uses, albeit rarely, the URI
(<a data-cite="ld-glossary#uniform-resource-identifier">Uniform Resource Indicator</a>)
terminology. While these terms are often used interchangeably among
technical communities, they do have important distinctions from one
another and the specification goes to great lengths to try and use the
proper terminology at all times.
</p>
</section>
<section class="informative">
<h2>Contributing</h2>
<p>There are a number of ways that one may participate in the development of
this specification:</p>
<ul>
<li>Technical discussion typically occurs on the working group mailing list:
<a href="https://lists.w3.org/Archives/Public/public-json-ld-wg/">[email protected]</a></li>
<li>The working group uses <a href="http://irc.w3.org/?channels=json-ld">#json-ld</a>
IRC channel is available for real-time discussion on <a href="http://irc.w3.org">irc.w3.org</a>.</li>
<li>The <a href="https://webchat.freenode.net/?channels=json-ld">#json-ld</a>
IRC channel is also available for real-time discussion on irc.freenode.net.</li>
</ul>
</section>
<section class="informative">
<h2>Typographical conventions</h2>
<div data-include="common/typographical-conventions.html"></div>
</section>
<section class="normative">
<h2>Terminology</h2>
<p>This document uses the following terms as defined in JSON [[!RFC8259]]. Refer
to the <a data-cite="RFC8259#section-2">JSON Grammar section</a> in [[!RFC8259]] for formal definitions.</p>
<div data-include="common/terms.html"
data-oninclude="restrictReferences">
</div>
</section>
<section class="informative">
<h2>Design Goals and Rationale</h2>
<p>JSON-LD satisfies the following design goals:</p>
<dl>
<dt>Simplicity</dt>
<dd>No extra processors or software libraries are necessary to use JSON-LD
in its most basic form. The language provides developers with a very easy
learning curve. Developers only need to know JSON and two
<a>keywords</a> (<code>@context</code>
and <code>@id</code>) to use the basic functionality in JSON-LD.</dd>
<dt>Compatibility</dt>
<dd>A JSON-LD document is always a valid JSON document. This ensures that
all of the standard JSON libraries work seamlessly with JSON-LD documents.</dd>
<dt>Expressiveness</dt>
<dd>The syntax serializes directed graphs. This ensures that almost
every real world data model can be expressed.</dd>
<dt>Terseness</dt>
<dd>The JSON-LD syntax is very terse and human readable, requiring as
little effort as possible from the developer.</dd>
<dt>Zero Edits, most of the time</dt>
<dd>JSON-LD ensures a smooth and simple transition from existing
JSON-based systems. In many cases,
zero edits to the JSON document and the addition of one line to the HTTP response
should suffice (see <a class="sectionRef" href="#interpreting-json-as-json-ld"></a>).
This allows organizations that have
already deployed large JSON-based infrastructure to use JSON-LD's features
in a way that is not disruptive to their day-to-day operations and is
transparent to their current customers. However, there are times where
mapping JSON to a graph representation is a complex undertaking.
In these instances, rather than extending JSON-LD to support
esoteric use cases, we chose not to support the use case. While Zero
Edits is a design goal, it is not always possible without adding
great complexity to the language. JSON-LD focuses on simplicity when
possible.</dd>
<dt>Usable as RDF</dt>
<dd>JSON-LD is usable by developers as
idiomatic JSON, with no need to understand RDF [[RDF11-CONCEPTS]].
JSON-LD is also usable as RDF, so people intending to use JSON-LD
with RDF tools will find it can be used like any other RDF syntax.
Complete details of how JSON-LD relates to RDF are in section
<a href="#relationship-to-rdf"></a>.</dd>
</dl>
</section>
<section class="informative">
<h2>Data Model Overview</h2>
<p>Generally speaking, the data model described by a
<a>JSON-LD document</a> is a labeled,
directed <a>graph</a>. The graph contains
<a>nodes</a>, which are connected by
<a>edges</a>. A <a>node</a> is typically data
such as a <a>string</a>, <a>number</a>,
<a>typed values</a> (like dates and times)
or an <a>IRI</a>.</p>
<p class="changed">Within a directed graph, nodes with may
be <em>unnamed</em>, i.e., not identified by an <a>IRI</a> or representing
data such as <a>strings</a> or <a>numbers</a>. Such nodes are called <a>blank nodes</a>,
and may be identified using a <a>blank node identifier</a>.
These identifiers may be required to represent a fully connected graph
using a tree structure, such as JSON, but otherwise have no
intrinsic meaning.</p>
<p>This simple data model is incredibly
flexible and powerful, capable of modeling almost any kind of
data. For a deeper explanation of the data model, see
section <a href="#data-model"></a>.</p>
<p>Developers who are familiar with Linked Data technologies will
recognize the data model as the RDF Data Model. To dive deeper into how
JSON-LD and RDF are related, see
section <a href="#relationship-to-rdf"></a>.</p>
<p>At the surface level, a <a>JSON-LD document</a> is simply
<a data-cite="RFC8259">JSON</a>, detailed in [[!RFC8259]].
For the purpose of describing the core data structures,
this is limited to <a>arrays</a>, <a>dictionaries</a> (the parsed version of a <a>JSON Object</a>),
<a>strings</a>, <a>numbers</a>, <a>booleans</a>, and <a>null</a>,
<span class="changed">called the <a>JSON-LD internal representation</a>.
This allows surface syntaxes other than JSON
to be manipulated using the same algorithms, when the syntax maps
to equivalent core data structures</span>.</p>
<p class="changed note">Although not discussed in this specification,
parallel work using <a data-cite="YAML">YAML</a> [[YAML]]
and binary representations such as <a data-cite="RFC7049">CBOR</a> [[RFC7049]]
could be used to map into the <a>internal representation</a>, allowing
the JSON-LD 1.1 API [[JSON-LD11-API]] to operate as if the source was a
JSON document.</p>
</section>
<section class="normative">
<h2>Syntax Tokens and Keywords</h2>
<p>JSON-LD specifies a number of syntax tokens and <a>keywords</a>
that are a core part of the language:</p>
<dl data-sort>
<dt><code>@context</code></dt>
<dd>Used to define the short-hand names that are used throughout a JSON-LD
document. These short-hand names are called <a>terms</a> and help
developers to express specific identifiers in a compact manner. The
<code>@context</code> keyword is described in detail in
<a class="sectionRef" href="#the-context"></a>.</dd>
<dt><code>@id</code></dt>
<dd>Used to uniquely identify <a>node objects</a> that are being described in the document
with <a>IRIs</a> or
<a>blank node identifiers</a>. This keyword
is described in <a class="sectionRef" href="#node-identifiers"></a>.</dd>
<dt><code>@value</code></dt>
<dd>Used to specify the data that is associated with a particular
<a>property</a> in the graph. This keyword is described in
<a class="sectionRef" href="#string-internationalization"></a> and
<a class="sectionRef" href="#typed-values"></a>.</dd>
<dt><code>@language</code></dt>
<dd>Used to specify the language for a particular string value or the default
language of a JSON-LD document. This keyword is described in
<a class="sectionRef" href="#string-internationalization"></a>.</dd>
<dt><code>@type</code></dt>
<dd>Used to set the data type of a <a>node</a> or
<a>typed value</a>. This keyword is described in
<a class="sectionRef" href="#typed-values"></a>.</dd>
<dt><code>@container</code></dt>
<dd>Used to set the default container type for a <a>term</a>.
This keyword is described in the following sections:
<ul>
<li><a class="sectionRef" href="#sets-and-lists"></a>,</li>
<li><a class="sectionRef" href="#data-indexing"></a>,</li>
<li><a class="sectionRef" href="#language-indexing"></a>,</li>
<li class="changed"><a class="sectionRef" href="#node-identifier-indexing"></a>,</li>
<li class="changed"><a class="sectionRef" href="#node-type-indexing"></a></li>
<li class="changed"><a class="sectionRef" href="#named-graphs"></a>,</li>
<li class="changed"><a class="sectionRef" href="#named-graph-indexing"></a>, and</li>
<li class="changed"><a class="sectionRef" href="#named-graph-data-indexing"></a></li>
</ul></dd>
<dt><code>@list</code></dt>
<dd>Used to express an ordered set of data.
This keyword is described in <a class="sectionRef" href="#lists"></a>.</dd>
<dt><code>@set</code></dt>
<dd>Used to express an unordered set of data and to ensure that values are always
represented as arrays. This keyword is described in
<a class="sectionRef" href="#sets"></a>.</dd>
<dt><code>@reverse</code></dt>
<dd>Used to express reverse properties. This keyword is described in
<a class="sectionRef" href="#reverse-properties"></a>.</dd>
<dt><code>@index</code></dt>
<dd>Used to specify that a container is used to index information and
that processing should continue deeper into a JSON data structure.
This keyword is described in <a class="sectionRef" href="#data-indexing"></a>.</dd>
<dt><code>@base</code></dt>
<dd>Used to set the <a>base IRI</a> against which to resolve those <a>relative IRIs</a>
interpreted relative to the document.
This keyword is described in <a class="sectionRef" href="#base-iri"></a>.</dd>
<dt><code>@vocab</code></dt>
<dd>Used to expand properties and values in <code>@type</code> with a common prefix
<a>IRI</a>. This keyword is described in <a class="sectionRef" href="#default-vocabulary"></a>.</dd>
<dt><code>@graph</code></dt><dd>Used to express a <a>graph</a>.
This keyword is described in <a class="sectionRef" href="#named-graphs"></a>.</dd>
<dt class="changed"><code>@nest</code></dt><dd class="changed">Collects a set of <a>nested properties</a> within
a <a>node object</a>.</dd>
<dt class="changed"><code>@none</code></dt><dd class="changed">Used as an index value
in an <a>id map</a>, <a>language map</a>, <a>type map</a>, or elsewhere where a dictionary is
used to index into other values.</dd>
<dt class="changed"><code>@prefix</code></dt><dd class="changed">
With the value <a>true</a>, allows this <a>term</a> to be used to construct a <a>compact IRI</a>
when compacting.</dd>
<dt class="changed"><code>@version</code></dt><dd class="changed">
Used in a <a>context definition</a> to set the <a>processing mode</a>.
New features since <a data-cite="JSON-LD">JSON-LD 1.0</a> [[!JSON-LD]] described in this specification are
only available when <a>processing mode</a> has been explicitly set to
<code>json-ld-1.1</code>.
</dd>
<dt><code>:</code></dt>
<dd>The separator for JSON keys and values that use
<a>compact IRIs</a>.</dd>
</dl>
<p>All keys, <a>keywords</a>, and values in JSON-LD are case-sensitive.</p>
</section>
</section>
<section id="conformance">
<p>Conformance criteria are relevant to authors and authoring tool implementers. As well
as sections marked as non-normative, all authoring guidelines, diagrams, examples,
and notes in this specification are non-normative. Everything else in this
specification is normative.</p>
<p>A <a>JSON-LD document</a> complies with this specification if it follows
the normative statements in appendix <a href="#json-ld-grammar"></a>. JSON documents
can be interpreted as JSON-LD by following the normative statements in
<a class="sectionRef" href="#interpreting-json-as-json-ld"></a>. For convenience, normative
statements for documents are often phrased as statements on the properties of the document.</p>
<p>This specification makes use of the following namespace prefixes:</p>
<table class="simple">
<thead><tr>
<th>Prefix</th>
<th>IRI</th>
</tr></thead>
<tbody>
<tr>
<td>dc</td>
<td>http://purl.org/dc/terms/</td>
</tr>
<tr>
<td>cred</td>
<td>https://w3id.org/credentials#</td>
</tr>
<tr>
<td>foaf</td>
<td>http://xmlns.com/foaf/0.1/</td>
</tr>
<tr>
<td>geojson</td>
<td>https://purl.org/geojson/vocab#</td>
</tr>
<tr>
<td>prov</td>
<td>http://www.w3.org/ns/prov#</td>
</tr>
<tr>
<td>rdf</td>
<td>http://www.w3.org/1999/02/22-rdf-syntax-ns#</td>
</tr>
<tr>
<td>schema</td>
<td>http://schema.org/</td>
</tr>
<tr>
<td>skos</td>
<td>http://www.w3.org/2004/02/skos/core#</td>
</tr>
<tr>
<td>xsd</td>
<td>http://www.w3.org/2001/XMLSchema#</td>
</tr>
</tbody>
</table>
<p>These are used within this document as part of a <a>compact IRI</a>
as a shorthand for the resulting <a>absolute IRI</a>, such as <code>dc:title</code>
used to represent <code>http://purl.org/dc/terms/title</code>.</p>
</section>
<section class="informative">
<h1>Basic Concepts</h1>
<p>JSON [[RFC8259]] is a lightweight, language-independent data interchange format.
It is easy to parse and easy to generate. However, it is difficult to integrate JSON
from different sources as the data may contain keys that conflict with other
data sources. Furthermore, JSON has no
built-in support for hyperlinks, which are a fundamental building block on
the Web. Let's start by looking at an example that we will be using for the
rest of this section:</p>
<pre class="example" data-transform="updateExample"
title="Sample JSON document">
<!--
{
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
}
-->
</pre>
<p>It's obvious to humans that the data is about a person whose
<code>name</code> is "Manu Sporny"
and that the <code>homepage</code> property contains the URL of that person's homepage.
A machine doesn't have such an intuitive understanding and sometimes,
even for humans, it is difficult to resolve ambiguities in such representations. This problem
can be solved by using unambiguous identifiers to denote the different concepts instead of
tokens such as "name", "homepage", etc.</p>
<p>Linked Data, and the Web in general, uses <a>IRIs</a>
(<a data-cite="RFC3987#section-2">Internationalized Resource Identifiers</a> as described in [[!RFC3987]]) for unambiguous
identification. The idea is to use <a>IRIs</a>
to assign unambiguous identifiers to data that may be of use to other developers.
It is useful for <a>terms</a>,
like <code>name</code> and <code>homepage</code>, to expand to <a>IRIs</a>
so that developers don't accidentally step on each other's terms. Furthermore, developers and
machines are able to use this <a>IRI</a> (by using a web browser, for instance) to go to
the term and get a definition of what the term means. This process is known as <a>IRI</a>
dereferencing.</p>
<p>Leveraging the popular <a href="http://schema.org/">schema.org vocabulary</a>,
the example above could be unambiguously expressed as follows:</p>
<aside class="example ds-selector-tabs"
title="Sample JSON-LD document using full IRIs instead of terms">
<div class="selectors">
<button class="selected" data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="expanded selected nohighlight" data-transform="updateExample">
<!--
{
"****http://schema.org/name****": "Manu Sporny",
"****http://schema.org/url****": ****{ "@id": ****"http://manu.sporny.org/" ****}****, ####← The '@id' keyword means 'This value is an identifier that is an IRI'####
"****http://schema.org/image****": ****{ "@id": ****"http://manu.sporny.org/images/manu.png" ****}****
}
-->
</pre>
<table class="statements"
data-result-for="Sample JSON-LD document using full IRIs instead of terms-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>schema:image</td><td>http://manu.sporny.org/images/manu.png</td></tr>
<tr><td>_:b0</td><td>schema:name</td><td>Manu Sporny</td></tr>
<tr><td>_:b0</td><td>schema:url</td><td>http://manu.sporny.org/</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="Sample JSON-LD document using full IRIs instead of terms-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[
schema:image <http://manu.sporny.org/images/manu.png>;
schema:name "Manu Sporny";
schema:url <http://manu.sporny.org/>
] .
-->
</pre>
</aside>
<p>In the example above, every property is unambiguously identified by an <a>IRI</a> and all values
representing <a>IRIs</a> are explicitly marked as such by the
<code>@id</code> <a>keyword</a>. While this is a valid JSON-LD
document that is very specific about its data, the document is also overly verbose and difficult
to work with for human developers. To address this issue, JSON-LD introduces the notion
of a <a>context</a> as described in the next section.</p>
<section class="informative">
<h2>The Context</h2>
<p>When two people communicate with one another, the conversation takes
place in a shared environment, typically called
"the context of the conversation". This shared context allows the
individuals to use shortcut terms, like the first name of a mutual friend,
to communicate more quickly but without losing accuracy. A context in
JSON-LD works in the same way. It allows two applications to use shortcut
terms to communicate with one another more efficiently, but without
losing accuracy.</p>
<p>Simply speaking, a <a>context</a> is used to map <a>terms</a> to
<a>IRIs</a>. <a>Terms</a> are case sensitive
and any valid <a>string</a> that is not a reserved JSON-LD <a>keyword</a>
can be used as a <a>term</a>.</p>
<p>For the sample document in the previous section, a <a>context</a> would
look something like this:</p>
<pre class="example nohighlight" data-transform="updateExample"
data-context-for="Sample JSON document"
title="Context for the sample document in the previous section">
<!--
{
****"@context": {
"name": "http://schema.org/name",**** ####← This means that 'name' is shorthand for 'http://schema.org/name'#### ****
"image": {
"@id": "http://schema.org/image",**** ####← This means that 'image' is shorthand for 'http://schema.org/image'#### ****
"@type": "@id"**** ####← This means that a string value associated with 'image' should be interpreted as an identifier that is an IRI#### ****
},
"homepage": {
"@id": "http://schema.org/url",**** ####← This means that 'homepage' is shorthand for 'http://schema.org/url'#### ****
"@type": "@id"**** ####← This means that a string value associated with 'homepage' should be interpreted as an identifier that is an IRI#### ****
}
}****
}
-->
</pre>
<p>As the <a>context</a> above shows, the value of a <a>term definition</a> can
either be a simple string, mapping the <a>term</a> to an <a>IRI</a>,
or a <a>dictionary</a>.</p>
<p>When a when a <a>member</a> with a <a>term</a> key has a <a>dictionary</a> value, the <a>dictionary</a> is called
an <a>expanded term definition</a>. The example above specifies that
the values of <code>image</code> and <code>homepage</code>, if they are
strings, are to be interpreted as
<a>IRIs</a>. <a>Expanded term definitions</a>
also allow terms to be used for <a href="#data-indexing">index maps</a>
and to specify whether <a>array</a> values are to be
interpreted as <a href="#sets">sets</a> or <a href="#lists">lists</a>.
<a>Expanded term definitions</a> may
be defined using <a data-lt="absolute IRI">absolute</a> or
<a>compact IRIs</a> as keys, which is
mainly used to associate type or language information with an
<a data-lt="absolute IRI">absolute</a> or <a>compact IRI</a>.</p>
<p><a>Contexts</a> can either be directly embedded
into the document or be referenced. Assuming the context document in the previous
example can be retrieved at <code>https://json-ld.org/contexts/person.jsonld</code>,
it can be referenced by adding a single line and allows a JSON-LD document to
be expressed much more concisely as shown in the example below:</p>
<aside class="example ds-selector-tabs"
title="Referencing a JSON-LD context">
<div class="selectors">
<button class="selected" data-selects="original">Original</button>
<button data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="original selected nohighlight" data-transform="updateExample">
<!--
{
****"@context": "https://json-ld.org/contexts/person.jsonld",****
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
}
-->
</pre>
<pre class="expanded nohighlight"
data-transform="updateExample"
data-result-for="Referencing a JSON-LD context-original">
<!--
[{
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}],
"http://xmlns.com/foaf/0.1/homepage": [{ "@id": "http://manu.sporny.org/" }],
"http://xmlns.com/foaf/0.1/img": [{ "@id": "http://manu.sporny.org/images/manu.png" }]
}]
-->
</pre>
<table class="statements"
data-result-for="Referencing a JSON-LD context-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>foaf:name</td><td>Manu Sporny</td></tr>
<tr><td>_:b0</td><td>foaf:homepage</td><td>http://manu.sporny.org/</td></tr>
<tr><td>_:b0</td><td>foaf:img</td><td>http://manu.sporny.org/images/manu.png</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="Referencing a JSON-LD context-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[
foaf:name "Manu Sporny";
foaf:homepage <http://manu.sporny.org/>;
foaf:img <http://manu.sporny.org/images/manu.png>
] .
-->
</pre>
</aside>
<p>The referenced context not only specifies how the terms map to
<a>IRIs</a> in the Schema.org vocabulary but also
specifies that string values associated with
the <code>homepage</code> and <code>image</code> property
can be interpreted as an <a>IRI</a> (<code>"@type": "@id"</code>,
see <a class="sectionRef" href="#iris"></a> for more details). This information allows developers
to re-use each other's data without having to agree to how their data will interoperate
on a site-by-site basis. External JSON-LD context documents may contain extra
information located outside of the <code>@context</code> key, such as
documentation about the <a>terms</a> declared in the
document. Information contained outside of the <code>@context</code> value
is ignored when the document is used as an external JSON-LD context document.</p>
<p>JSON documents can be interpreted as JSON-LD without having to be modified by
referencing a <a>context</a> via an <a data-cite="RFC8288#section-3">HTTP Link Header</a>
as described in <a class="sectionRef" href="#interpreting-json-as-json-ld"></a>. It is also
possible to apply a custom context using the JSON-LD 1.1 API [[JSON-LD11-API]].</p>
<p>In <a>JSON-LD documents</a>,
<a>contexts</a> may also be specified inline.
This has the advantage that documents can be processed even in the
absence of a connection to the Web. Ultimately, this is a modeling decision
and different use cases may require different handling.</p>
<aside class="example ds-selector-tabs"
title="In-line context definition">
<div class="selectors">
<button class="selected" data-selects="original">Original</button>
<button data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="original selected nohighlight" data-transform="updateExample">
<!--
{
****"@context": {
"name": "http://schema.org/name",
"image": {
"@id": "http://schema.org/image",
"@type": "@id"
},
"homepage": {
"@id": "http://schema.org/url",
"@type": "@id"
}
},****
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
}
-->
</pre>
<pre class="expanded nohighlight" data-transform="updateExample"
data-result-for="In-line context definition-original">
<!--
[{
"http://schema.org/name": [{"@value": "Manu Sporny"}],
"http://schema.org/url": [{ "@id": "http://manu.sporny.org/" }],
"http://schema.org/image": [{ "@id": "http://manu.sporny.org/images/manu.png" }]
}]
-->
</pre>
<table class="statements"
data-result-for="In-line context definition-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>schema:image</td><td>http://manu.sporny.org/images/manu.png</td></tr>
<tr><td>_:b0</td><td>schema:name</td><td>Manu Sporny</td></tr>
<tr><td>_:b0</td><td>schema:url</td><td>http://manu.sporny.org/</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="In-line context definition-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[
schema:image <http://manu.sporny.org/images/manu.png>;
schema:name "Manu Sporny";
schema:url <http://manu.sporny.org/>
] .
-->
</pre>
</aside>
<p>This section only covers the most basic features of the JSON-LD Context.
The Context can also be used to help interpret other more
complex JSON data structures, such as <a href="#indexed-values">indexed values</a>,
<a href="#sets-and-lists">ordered values</a>, and
<a href="#nested-properties">nested properties</a>.
More advanced features related to the JSON-LD Context are covered in
section <a href="#advanced-concepts" class="sectionRef"></a>.</p>
</section>
<section class="informative">
<h2>IRIs</h2>
<p><a>IRIs</a> (<a data-cite="RFC3987#section-2">Internationalized Resource Identifiers</a>
[[!RFC3987]]) are fundamental to Linked Data as that is how most
<a>nodes</a> and <a>properties</a>
are identified. In JSON-LD, IRIs may be represented as an
<a>absolute IRI</a> or a <a>relative IRI</a>. An
<a data-cite="RFC3987#section-1.3">absolute IRI</a> is defined in [[!RFC3987]] as containing a
<em>scheme</em> along with <em>path</em> and optional <em>query</em> and
<em>fragment</em> segments. A <a>relative IRI</a> is an IRI
that is relative to some other <a>absolute IRI</a>.
In JSON-LD, with exceptions are as described below, all <a>relative IRIs</a>
are resolved relative to the <a>base IRI</a>.</p>
<p class="note"><a>Properties</a>, values of <code>@type</code>,
and values of <a>properties</a> with a <a>term definition</a>
that defines them as being relative to the <a>vocabulary mapping</a>,
may have the form of a <a>relative IRI</a>, but are resolved using the
<a>vocabulary mapping</a>, and not the <a>base IRI</a>.</p>
<p>A <a>string</a> is interpreted as an <a>IRI</a> when it is the
value of an <a>dictionary member</a> with the key<code>@id</code>:</p>
<pre class="example nohighlight" data-transform="updateExample"
title="Values of @id are interpreted as IRI">
<!--
{
####...####
"homepage": { "****@id****": "http://example.com/" }
####...####
}
-->
</pre>
<p>Values that are interpreted as <a>IRIs</a>, can also be
expressed as <a>relative IRIs</a>. For example,
assuming that the following document is located at
<code>http://example.com/about/</code>, the <a>relative IRI</a>
<code>../</code> would expand to <code>http://example.com/</code> (for more
information on where <a>relative IRIs</a> can be
used, please refer to section <a href="#json-ld-grammar"></a>).</p>
<pre class="example nohighlight" data-transform="updateExample"
title="IRIs can be relative">
<!--
{
####...####
"homepage": { "****@id****": "../" }
####...####
}
-->
</pre>
<p><a>Absolute IRIs</a> can be expressed directly
in the key position like so:</p>
<pre class="example nohighlight" data-transform="updateExample"
title="IRI as a key">
<!--
{
####...####
"****http://schema.org/name****": "Manu Sporny"####,
...####
}
-->
</pre>
<p>In the example above, the key <code>http://schema.org/name</code>
is interpreted as an <a>absolute IRI</a>.</p>