-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathindex.html
More file actions
4085 lines (3626 loc) · 153 KB
/
index.html
File metadata and controls
4085 lines (3626 loc) · 153 KB
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"></script>
<script type="text/javascript" src="../common/common.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: "CG-DRAFT",
// if you wish the publication date to be other than today, set this
//publishDate: "2013-11-05",
copyrightStart: "2010",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "json-ld",
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/2014/REC-json-ld-20140116/",
previousPublishDate: "2014-01-16",
previousMaturity: "REC",
previousDiffURI: "http://www.w3.org/TR/2014/REC-json-ld-20140116/",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "http://json-ld.org/spec/latest/json-ld/",
issueBase: "https://github.com/json-ld/json-ld.org/issues/",
githubAPI: "https://api.github.com/repos/json-ld/json-ld.org",
includePermalinks: true,
noRecTrack: false,
testSuiteURIkey: "http://json-ld.org/test-suite/",
postProcess: [internalizeTermListReferences],
// 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: "Manu Sporny", url: "http://manu.sporny.org/",
company: "Digital Bazaar", companyURL: "http://digitalbazaar.com/" },
{ name: "Gregg Kellogg", url: "http://greggkellogg.net/",
company: "Kellogg Associates", companyURL: "http://kellogg-assoc.com/" },
{ name: "Markus Lanthaler", url: "http://www.markus-lanthaler.com/",
company: "Graz University of Technology", companyURL: "http://www.tugraz.at/" }
],
// 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://digitalbazaar.com/",
company: "Digital Bazaar", companyURL: "http://digitalbazaar.com/" },
{ name: "Dave Longley", url: "http://digitalbazaar.com/",
company: "Digital Bazaar", companyURL: "http://digitalbazaar.com/"},
{ name: "Gregg Kellogg", url: "http://greggkellogg.net/",
company: "Kellogg Associates", companyURL: "http://kellogg-assoc.com/" },
{ name: "Markus Lanthaler", url: "http://www.markus-lanthaler.com/",
company: "Graz University of Technology", companyURL: "http://www.tugraz.at/" },
{ name: "Niklas Lindström", url: "http://neverspace.net/" }
],
bugTracker: {
open: "https://github.com/json-ld/json-ld.org/issues?utf8=✓&q=is%3Aissue%20label%3Asyntax%20is%3Aopen%20milestone%3A%22JSON-LD%201.1%22%20",
new: "https://github.com/json-ld/json-ld.org/issues/new"
},
otherLinks: [{
key: "Version control",
data: [{
value: "Github Repository",
href: "https://github.com/json-ld/json-ld.org"
}]
}],
// name of the WG
wg: "JSON for Linking Data W3C Community Group",
// URI of the public WG page
wgURI: "http://www.w3.org/community/json-ld/",
// name (with the @w3c.org) of the public mailing to which comments are due
wgPublicList: "public-linked-json",
// 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: "http://www.w3.org/2004/01/pp-impl/46168/status",
maxTocLevel: 2
//alternateFormats: [ {uri: "diff-20130910.html", label: "diff to previous version"} ]
};
//]]>
</script>
<style type="text/css">
.highlight { 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; }
.highlight {
font-weight: bold;
color: #0a3;
}
.comment {
color: #999;
}
.changed {
background-color: rgb(215, 238, 197);
}
.changed:hover {
color: green;
background-color: inherit;
}
</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="http://www.w3.org/community/json-ld/">JSON for Linking Data W3C Community Group</a>.
The document has been transferred to the RDF Working Group for review, improvement,
and publication along the Recommendation track. The specification has undergone
significant development, review, and changes during the course of several years.</p>
<!--<p>There are several independent
<a href="http://json-ld.org/test-suite/reports/">interoperable implementations</a> of
this specification, a test suite [[JSON-LD-TESTS]] and a
<a href="http://json-ld.org/playground/">live JSON-LD editor</a> that is capable
of demonstrating the features described in this document.</p> -->
</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 [[!RFC7159]]. 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>JSON object</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 Graph
or <a>RDF 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, like Turtle [[TURTLE]]. 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 graph, or an <a>RDF Dataset</a> in a JSON syntax</li>
</ul>
<p>A companion document, the JSON-LD Processing Algorithms and API specification
[[JSON-LD-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
JSON, which is detailed in [[!RFC7159]].</p>
<p>This document almost exclusively uses the term IRI
(<a href="http://www.w3.org/TR/ld-glossary/#internationalized-resource-identifier">Internationalized Resource Indicator</a>)
when discussing hyperlinks. Many Web developers are more familiar with the
URL (<a href="http://www.w3.org/TR/ld-glossary/#uniform-resource-locator">Uniform Resource Locator</a>)
terminology. The document also uses, albeit rarely, the URI
(<a href="http://www.w3.org/TR/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>
<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 public mailing list:
<a href="http://lists.w3.org/Archives/Public/public-linked-json/">public-linked-json@w3.org</a></li>
<!--<li><a href="http://json-ld.org/minutes/">Public teleconferences</a> are held
on Tuesdays at 1500UTC on the second and fourth week of each month.</li> -->
<li>The <a href="http://webchat.freenode.net/?channels=json-ld">#json-ld</a>
IRC channel is available for real-time discussion on irc.freenode.net.</li>
</ul>
</section>
<section class="normative">
<h3>Terminology</h3>
<div data-include="../common/terms.html"
data-oninclude="restrictReferences"></div>
</section>
<section>
<h2>Typographical conventions</h2>
<div data-include="../common/typographical-conventions.html"></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 used for JSON-LD 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>.
There is also a special class of <a>node</a> called a
<a>blank node</a>, which is typically used to express data that does
not have a global identifier like an <a>IRI</a>.
<a>Blank nodes</a> are identified using a
<a>blank node identifier</a>. 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>
</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>
<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 <em>things</em> 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 <a class="sectionRef" href="#sets-and-lists"></a>.</dd>
<dt><code>@list</code></dt>
<dd>Used to express an ordered set of data.
This keyword is described in <a class="sectionRef" href="#sets-and-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-and-lists"></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 <a>relative IRIs</a>
are resolved. 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><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>
</section>
<section class="informative">
<h1>Basic Concepts</h1>
<p>JSON [[RFC7159]] 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>
(Internationalized Resource Identifiers 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>
<pre class="example" data-transform="updateExample"
title="Sample JSON-LD document using full IRIs instead of terms">
<!--
{
"****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>
<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" data-transform="updateExample"
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>JSON object</a>.</p>
<p>When a <a>JSON object</a> is associated with a term, it 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-and-lists">sets or 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>http://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>
<pre class="example" data-transform="updateExample"
title="Referencing a JSON-LD context">
<!--
{
****"@context": "http://json-ld.org/contexts/person.jsonld",****
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
}
-->
</pre>
<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 HTTP Link Header
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 API [[JSON-LD-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>
<pre class="example" data-transform="updateExample"
title="In-line context definition">
<!--
{
****"@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>
<p>This section only covers the most basic features of the JSON-LD
Context. 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> (Internationalized Resource Identifiers
[[!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>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 all <a>relative IRIs</a> are resolved
relative to 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 <code>@id</code> member:</p>
<pre class="example" 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" 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" 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>
<p>Term-to-IRI expansion occurs if the key matches a <a>term</a> defined
within the <a>active context</a>:</p>
<pre class="example" data-transform="updateExample"
title="Term expansion from context definition">
<!--
{
"****@context****":
{
"****name****": "****http://schema.org/name****"
},
"****name****": "Manu Sporny",
"status": "trollin'"
}
-->
</pre>
<p>JSON keys that do not expand to an <a>IRI</a>, such as <code>status</code>
in the example above, are not Linked Data and thus ignored when processed.</p>
<p>If type <a>coercion</a> rules are specified in the <code>@context</code> for
a particular <a>term</a> or property IRI, an IRI is generated:</p>
<pre class="example" data-transform="updateExample"
title="Type coercion">
<!--
{****
"@context":
{
...
"homepage":
{
"@id": "http://schema.org/url",
"@type": "@id"
}
...
}****
...
"homepage": "http://manu.sporny.org/",
...
}
-->
</pre>
<p>In the example above, since the value <code>http://manu.sporny.org/</code>
is expressed as a JSON <a>string</a>, the type <a>coercion</a>
rules will transform the value into an IRI when processing the data.
See <a class="sectionRef" href="#type-coercion"></a> for more
details about this feature.</p>
<p>In summary, <a>IRIs</a> can be expressed in a variety of
different ways in JSON-LD:</p>
<ol>
<li><a>JSON object</a> keys that have a <a>term</a> mapping in
the <a>active context</a> expand to an <a>IRI</a>
(only applies outside of the <a>context definition</a>).</li>
<li>An <a>IRI</a> is generated for the <a>string</a> value specified using
<code>@id</code> or <code>@type</code>.</li>
<li>An <a>IRI</a> is generated for the <a>string</a> value of any key for which there
are <a>coercion</a> rules that contain an <code>@type</code> key that is
set to a value of <code>@id</code> or <code>@vocab</code>.</li>
</ol>
<p>This section only covers the most basic features associated with IRIs
in JSON-LD. More advanced features related to IRIs are covered in
section <a href="#advanced-concepts"></a>.
</p>
</section>
<section class="informative">
<h2>Node Identifiers</h2>
<p>To be able to externally reference <a>nodes</a>
in a <a>graph</a>, it is important that
<a>nodes</a> have an identifier. <a>IRIs</a>
are a fundamental concept of Linked Data, for
<a>nodes</a> to be truly linked, dereferencing the
identifier should result in a representation of that <a>node</a>.
This may allow an application to retrieve further information about a
<a>node</a>.</p>
<p>In JSON-LD, a <a>node</a> is identified using the <code>@id</code>
<a>keyword</a>:</p>
<pre class="example" data-transform="updateExample"
title="Identifying a node">
<!--
{
"@context":
{
...
"name": "http://schema.org/name"
},
****"@id": "http://me.markus-lanthaler.com/"****,
"name": "Markus Lanthaler",
...
}
-->
</pre>
<p>The example above contains a <a>node object</a> identified by the IRI
<code>http://me.markus-lanthaler.com/</code>.</p>
<p>This section only covers the most basic features associated with
node identifiers in JSON-LD. More advanced features related to
node identifiers are covered in section <a href="#advanced-concepts"></a>.
</p>
</section>
<section class="informative">
<h2>Specifying the Type</h2>
<p>The type of a particular node can be specified using the <code>@type</code>
<a>keyword</a>. In Linked Data, types are uniquely
identified with an <a>IRI</a>.</p>
<pre class="example" data-transform="updateExample"
title="Specifying the type for a node">
<!--
{
...
"@id": "http://example.org/places#BrewEats",
"****@type****": "****http://schema.org/Restaurant****",
...
}
-->
</pre>
<p>A node can be assigned more than one type by using an <a>array</a>:</p>
<pre class="example" data-transform="updateExample"
title="Specifying multiple types for a node">
<!--
{
...
"@id": "http://example.org/places#BrewEats",
"****@type****": ****[ "http://schema.org/Restaurant", "http://schema.org/Brewery" ],****
...
}
-->
</pre>
<p>The value of an <code>@type</code> key may also be a <a>term</a> defined in the <a>active context</a>:</p>
<pre class="example" data-transform="updateExample"
title="Using a term to specify the type">
<!--
{
"@context": {
...
****"Restaurant": "http://schema.org/Restaurant", ****
****"Brewery": "http://schema.org/Brewery"****
}
"@id": "http://example.org/places#BrewEats",
****"@type": [ "Restaurant", "Brewery" ]****,
...
}
-->
</pre>
<p class="note">This section only covers the most basic features associated with
types in JSON-LD. It is worth noting that the <code>@type</code>
<a>keyword</a> is not only used to specify the type of a
<a>node</a> but also to express <a>typed values</a>
(as described in <a class="sectionRef" href="#typed-values"></a>) and to
<a data-lt="coercion">type coerce</a> values (as described in
<a class="sectionRef" href="#type-coercion"></a>). Specifically, <code>@type</code>
cannot be used in a <a>context</a> to define a <a>node</a>'s
type. For a detailed description of the differences, please refer to
<a class="sectionRef" href="#typed-values"></a>.</p>
</section>
</section>
<section class="normative">
<h1>Advanced Concepts</h1>
<p>JSON-LD has a number of features that provide functionality above and beyond
the core functionality described above. The following section describes this
advanced functionality in more detail.</p>
<section class="informative">
<h2>Base IRI</h2>
<p>JSON-LD allows <a>IRI</a>s to be specified in a relative form which is
resolved against the document base according
<cite><a href="http://tools.ietf.org/html/rfc3986#section-5.1">section 5.1 Establishing a Base URI</a></cite>
of [[RFC3986]]. The <a>base IRI</a> may be explicitly set with a <a>context</a>
using the <code>@base</code> keyword.</p>
<p>For example, if a JSON-LD document was retrieved from <code>http://example.com/document.jsonld</code>,
relative IRIs would resolve against that IRI:</p>
<pre class="example" data-transform="updateExample"
title="Use a relative IRI as node identifier">
<!--
{
"@context": {
"label": "http://www.w3.org/2000/01/rdf-schema#label"
},
****"@id": ""****,
"label": "Just a simple document"
}
-->
</pre>
<p>This document uses an empty <code>@id</code>, which resolves to the document base.
However, if the document is moved to a different location, the <a>IRI</a> would change.
To prevent this without having to use an <a>absolute IRI</a>, a <a>context</a>
may define an <code>@base</code> mapping, to overwrite the <a>base IRI</a> for the document.</p>
<pre class="example" data-transform="updateExample"
title="Setting the document base in a document">
<!--
{
"@context": {
****"@base": "http://example.com/document.jsonld"****
},
"@id": "",
"label": "Just a simple document"
}
-->
</pre>
<p>Setting <code>@base</code> to <a>null</a> will prevent
<a>relative IRIs</a> to be expanded to
<a>absolute IRIs</a>.</p>
<p>Please note that the <code>@base</code> will be ignored if used in
external contexts.</p>
</section>
<section class="informative">
<h2>Default Vocabulary</h2>
<p>At times, all properties and types may come from the same vocabulary. JSON-LD's
<code>@vocab</code> keyword allows an author to set a common prefix which
is used as the <a>vocabulary mapping</a> and is used
for all properties and types that do not match a <a>term</a> and are neither
a <a>compact IRI</a> nor an <a>absolute IRI</a> (i.e., they do
not contain a colon).</p>
<pre class="example" data-transform="updateExample"
title="Using a common vocabulary prefix">
<!--
{
"@context": {
****"@vocab": "http://schema.org/"****
}
"@id": "http://example.org/places#BrewEats",
"@type": ****"Restaurant"****,
****"name"****: "Brew Eats"
...
}
-->
</pre>
<p>If <code>@vocab</code> is used but certain keys in an
<a data-lt="JSON object">object</a> should not be expanded using
the vocabulary <a>IRI</a>, a <a>term</a> can be explicitly set
to <a>null</a> in the <a>context</a>. For instance, in the
example below the <code>databaseId</code> member would not expand to an
<a>IRI</a>.</p>
<pre class="example" data-transform="updateExample"
title="Using the null keyword to ignore data">
<!--
{
"@context":
{
"@vocab": "http://schema.org/",
****"databaseId": null****
},
"@id": "http://example.org/places#BrewEats",
"@type": "Restaurant",
"name": "Brew Eats",
****"databaseId"****: "23987520"
}
-->
</pre>
</section>
<section class="informative">
<h2>Compact IRIs</h2>
<p>A <a>compact IRI</a> is a way of expressing an <a>IRI</a>
using a <em>prefix</em> and <em>suffix</em> separated by a colon (<code>:</code>).
The <a>prefix</a> is a <a>term</a> taken from the
<a>active context</a> and is a short string identifying a
particular <a>IRI</a> in a JSON-LD document. For example, the
prefix <code>foaf</code> may be used as a short hand for the
Friend-of-a-Friend vocabulary, which is identified using the <a>IRI</a>
<code>http://xmlns.com/foaf/0.1/</code>. A developer may append
any of the FOAF vocabulary terms to the end of the prefix to specify a short-hand
version of the <a>absolute IRI</a> for the vocabulary term. For example,
<code>foaf:name</code> would be expanded to the IRI
<code>http://xmlns.com/foaf/0.1/name</code>.</p>
<pre class="example" data-transform="updateExample"
title="Prefix expansion">
<!--
{
"****@context****":
{
"****foaf****": "****http://xmlns.com/foaf/0.1/****"
...
},
"@type": "****foaf:Person****"
"****foaf:name****": "Dave Longley",
...
}
-->
</pre>
<p>In the example above, <code>foaf:name</code> expands to the <a>IRI</a>
<code>http://xmlns.com/foaf/0.1/name</code> and <code>foaf:Person</code> expands
to <code>http://xmlns.com/foaf/0.1/Person</code>.</p>
<p><a>Prefixes</a> are expanded when the form of the value
is a <a>compact IRI</a> represented as a <code>prefix:suffix</code>
combination, the <em>prefix</em> matches a <a>term</a> defined within the