forked from json-ld/json-ld.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2381 lines (2092 loc) · 182 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
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" typeof="bibo:Document">
<head>
<title>JSON-LD API 1.0</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!--
=== NOTA BENE ===
For the three scripts below, if your spec resides on dev.w3 you can check them
out in the same tree and use relative links so that they'll work offline,
-->
<style type="text/css">
.diff { font-weight:bold; color:#0a3; }
</style>
<style type="text/css">/*****************************************************************
* ReSpec 3 CSS
* Robin Berjon - http://berjon.com/
*****************************************************************/
/* --- INLINES --- */
em.rfc2119 {
text-transform: lowercase;
font-variant: small-caps;
font-style: normal;
color: #900;
}
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
border: none;
}
dfn {
font-weight: bold;
}
a.internalDFN {
color: inherit;
border-bottom: 1px solid #99c;
text-decoration: none;
}
a.externalDFN {
color: inherit;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
a.bibref {
text-decoration: none;
}
cite .bibref {
font-style: normal;
}
code {
color: #ff4500;
}
/* --- --- */
ol.algorithm { counter-reset:numsection; list-style-type: none; }
ol.algorithm li { margin: 0.5em 0; }
ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }
/* --- WEB IDL --- */
pre.idl {
border-top: 1px solid #90b8de;
border-bottom: 1px solid #90b8de;
padding: 1em;
line-height: 120%;
}
pre.idl::before {
content: "WebIDL";
display: block;
width: 150px;
background: #90b8de;
color: #fff;
font-family: initial;
padding: 3px;
font-weight: bold;
margin: -1em 0 1em -1em;
}
.idlType {
color: #ff4500;
font-weight: bold;
text-decoration: none;
}
/*.idlModule*/
/*.idlModuleID*/
/*.idlInterface*/
.idlInterfaceID, .idlDictionaryID, .idlCallbackID, .idlEnumID {
font-weight: bold;
color: #005a9c;
}
.idlSuperclass {
font-style: italic;
color: #005a9c;
}
/*.idlAttribute*/
.idlAttrType, .idlFieldType, .idlMemberType {
color: #005a9c;
}
.idlAttrName, .idlFieldName, .idlMemberName {
color: #ff4500;
}
.idlAttrName a, .idlFieldName a, .idlMemberName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlMethod*/
.idlMethType, .idlCallbackType {
color: #005a9c;
}
.idlMethName {
color: #ff4500;
}
.idlMethName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlParam*/
.idlParamType {
color: #005a9c;
}
.idlParamName {
font-style: italic;
}
.extAttr {
color: #666;
}
/*.idlConst*/
.idlConstType {
color: #005a9c;
}
.idlConstName {
color: #ff4500;
}
.idlConstName a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
/*.idlException*/
.idlExceptionID {
font-weight: bold;
color: #c00;
}
.idlTypedefID, .idlTypedefType {
color: #005a9c;
}
.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
color: #c00;
font-weight: normal;
}
.excName a {
font-family: monospace;
}
.idlRaises a.idlType, .excName a.idlType {
border-bottom: 1px dotted #c00;
}
.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
width: 45px;
text-align: center;
}
.excGetSetTrue, .prmNullTrue, .prmOptTrue { color: #0c0; }
.excGetSetFalse, .prmNullFalse, .prmOptFalse { color: #c00; }
.idlImplements a {
font-weight: bold;
}
dl.attributes, dl.methods, dl.constants, dl.fields, dl.dictionary-members {
margin-left: 2em;
}
.attributes dt, .methods dt, .constants dt, .fields dt, .dictionary-members dt {
font-weight: normal;
}
.attributes dt code, .methods dt code, .constants dt code, .fields dt code, .dictionary-members dt code {
font-weight: bold;
color: #000;
font-family: monospace;
}
.attributes dt code, .fields dt code, .dictionary-members dt code {
background: #ffffd2;
}
.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code {
color: #005a9c;
background: transparent;
font-family: inherit;
font-weight: normal;
font-style: italic;
}
.methods dt code {
background: #d9e6f8;
}
.constants dt code {
background: #ddffd2;
}
.attributes dd, .methods dd, .constants dd, .fields dd, .dictionary-members dd {
margin-bottom: 1em;
}
table.parameters, table.exceptions {
border-spacing: 0;
border-collapse: collapse;
margin: 0.5em 0;
width: 100%;
}
table.parameters { border-bottom: 1px solid #90b8de; }
table.exceptions { border-bottom: 1px solid #deb890; }
.parameters th, .exceptions th {
color: #fff;
padding: 3px 5px;
text-align: left;
font-family: initial;
font-weight: normal;
text-shadow: #666 1px 1px 0;
}
.parameters th { background: #90b8de; }
.exceptions th { background: #deb890; }
.parameters td, .exceptions td {
padding: 3px 10px;
border-top: 1px solid #ddd;
vertical-align: top;
}
.parameters tr:first-child td, .exceptions tr:first-child td {
border-top: none;
}
.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
width: 100px;
}
.parameters td.prmType {
width: 120px;
}
table.exceptions table {
border-spacing: 0;
border-collapse: collapse;
width: 100%;
}
/* --- TOC --- */
.toc a, .tof a {
text-decoration: none;
}
a .secno, a .figno {
color: #000;
}
ul.tof, ol.tof {
list-style: none outside none;
}
.caption {
margin-top: 0.5em;
font-style: italic;
}
/* --- TABLE --- */
table.simple {
border-spacing: 0;
border-collapse: collapse;
border-bottom: 3px solid #005a9c;
}
.simple th {
background: #005a9c;
color: #fff;
padding: 3px 5px;
text-align: left;
}
.simple th[scope="row"] {
background: inherit;
color: inherit;
border-top: 1px solid #ddd;
}
.simple td {
padding: 3px 10px;
border-top: 1px solid #ddd;
}
.simple tr:nth-child(even) {
background: #f0f6ff;
}
/* --- DL --- */
.section dd > p:first-child {
margin-top: 0;
}
.section dd > p:last-child {
margin-bottom: 0;
}
.section dd {
margin-bottom: 1em;
}
.section dl.attrs dd, .section dl.eldef dd {
margin-bottom: 0;
}
</style><style type="text/css">/* --- EXAMPLES --- */
div.example-title {
min-width: 7.5em;
color: #b9ab2d;
}
div.example-title span {
text-transform: uppercase;
}
div.example, div.illegal-example {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
div.illegal-example { color: red }
div.illegal-example p { color: black }
div.example {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
border-color: #e0cb52;
background: #fcfaee;
}
</style><style type="text/css">/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title {
padding-right: 1em;
min-width: 7.5em;
color: #b9ab2d;
}
div.issue-title { color: #e05252; }
div.note-title { color: #52e052; }
div.issue-title span, div.note-title span {
text-transform: uppercase;
}
div.note, div.issue {
margin-top: 1em;
margin-bottom: 1em;
}
.note > p:first-child, .issue > p:first-child { margin-top: 0 }
.issue, .note {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
}
div.issue, div.note {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
span.note, span.issue { padding: .1em .5em .15em; }
.issue {
border-color: #e05252;
background: #fbe9e9;
}
.note {
border-color: #52e052;
background: #e9fbe9;
}
</style><link rel="stylesheet" href="http://www.w3.org/community/src/css/spec/cg-final.css" /><script type="text/javascript" src="http://s3.amazonaws.com/green-turtle/RDFa.0.15.0.js"></script><meta name="green-turtle-rdfa-message" content="{ "type": "status", "loaded": true, "count": 45 }" /></head>
<body><div class="head">
<p>
<a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C" /></a>
</p>
<h1 class="title" id="title">JSON-LD API 1.0</h1>
<h2 id="subtitle">An Application Programming Interface for the JSON-LD Syntax</h2>
<h2 id="final-community-group-specification-26-june-2012">Final Community Group Specification 26 June 2012</h2>
<dl>
<dt>Latest editor's draft:</dt>
<dd><a href="http://json-ld.org/spec/latest/json-ld-api/">http://json-ld.org/spec/latest/json-ld-api/</a></dd>
<dt>Editors:</dt>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Manu Sporny" href="http://manu.sporny.org/">Manu Sporny</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Gregg Kellogg" href="http://greggkellogg.net/">Gregg Kellogg</a>, <a rel="foaf:workplaceHomepage" href="http://kellogg-assoc.com/">Kellogg Associates</a></span>
</dd>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Dave Longley" href="http://digitalbazaar.com/">Dave Longley</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Markus Lanthaler" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a>, <a rel="foaf:workplaceHomepage" href="http://www.tugraz.at/">Graz University of Technology</a></span>
</dd>
<dt>Authors:</dt>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Dave Longley" href="http://digitalbazaar.com/">Dave Longley</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Manu Sporny" href="http://digitalbazaar.com/">Manu Sporny</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Gregg Kellogg" href="http://greggkellogg.net/">Gregg Kellogg</a>, <a rel="foaf:workplaceHomepage" href="http://kellogg-assoc.com/">Kellogg Associates</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Markus Lanthaler" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a>, <a rel="foaf:workplaceHomepage" href="http://www.tugraz.at/">Graz University of Technology</a></span>
</dd>
</dl>
<p>
This document is also available in this non-normative format:
<a href="diff-20120524.html">diff to previous version</a>
</p>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2010-2012
the Contributors to the JSON-LD API 1.0 Specification, published by the
<a href="http://www.w3.org/community/json-ld/">JSON for Linking Data Community Group</a> under the
<a href="https://www.w3.org/community/about/agreements/fsa/">W3C Community Final Specification Agreement (FSA)</a>.
A human-readable <a href="http://www.w3.org/community/about/agreements/fsa-deed/">summary</a> is available.
</p>
<hr />
</div>
<div id="abstract" class="introductory section"><h2>Abstract</h2>
<p>
JSON [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC4627">RFC4627</a></cite>] has proven to be a highly useful object serialization and
messaging format. JSON-LD [<cite><a class="bibref" rel="biblioentry" href="#bib-JSON-LD">JSON-LD</a></cite>] harmonizes the representation of
Linked Data in JSON by outlining a common JSON representation format for
expressing directed graphs; mixing both Linked Data and non-Linked Data in
a single document. This document outlines an Application Programming
Interface and a set of algorithms for programmatically transforming
JSON-LD documents in order to make them easier to work with in programming
environments like JavaScript, Python, and Ruby.
</p>
</div><div id="sotd" class="introductory section"><h2>Status of This Document</h2>
<p>
This specification was published by the <a href="http://www.w3.org/community/json-ld/">JSON for Linking Data Community Group</a>.
It is not a W3C Standard nor is it on the W3C Standards Track.
Please note that under the
<a href="https://www.w3.org/community/about/agreements/final/">W3C Community Final Specification Agreement (FSA)</a>
other conditions apply.
Learn more about
<a href="http://www.w3.org/community/">W3C Community and Business Groups</a>.
</p>
<p>This document has been under development for over 18 months in the
JSON for Linking Data Community Group. The document has recently been
approved for transfer into the RDF Working Group for
review with the intent to publish the
document along the W3C
Recommendation track. This specification has undergone significant
development, review, and changes during the course of the last 18
months and is being published as a Final Community Group Specification so that
it may gain wider review and feedback.
</p>
<p>
There are currently
<a href="http://json-ld.org/#impl">five interoperable implementations</a>
of this specification. There is
a <a href="https://github.com/json-ld/json-ld.org/tree/master/test-suite">fairly complete test suite</a>
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. While development on implementations, the test suite
and the live editor will continue, they are believed to be mature enough
to be integrated into a non-production system at this point in time with
the expectation that they could be used in a production system within the
next year.
</p>
<div class="issue"><div class="issue-title"><span>Issue 1</span></div><p class="">
It is important for readers to understand that the scope of this document is
currently under debate and new features may be added to the specification.
Existing features may be modified heavily or removed entirely from the
specification upon further review and feedback from the broader community.
This is a work in progress and publication as a First Public Working Draft
does not require that all Working Group members agree on the content of the
document.
</p></div>
</div><div id="toc" class="section"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#preface" class="tocxref"><span class="secno">1. </span>Preface</a><ul class="toc"><li class="tocline"><a href="#contributing" class="tocxref"><span class="secno">1.1 </span>Contributing</a></li></ul></li><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">2. </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#expansion" class="tocxref"><span class="secno">2.1 </span>Expansion</a></li><li class="tocline"><a href="#compaction" class="tocxref"><span class="secno">2.2 </span>Compaction</a></li><li class="tocline"><a href="#conversion-to-and-from-rdf" class="tocxref"><span class="secno">2.3 </span>Conversion to and from RDF</a></li><li class="tocline"><a href="#framing-and-normalization" class="tocxref"><span class="secno">2.4 </span>Framing and Normalization</a></li></ul></li><li class="tocline"><a href="#the-application-programming-interface" class="tocxref"><span class="secno">3. </span>The Application Programming Interface</a><ul class="toc"><li class="tocline"><a href="#general-terminology" class="tocxref"><span class="secno">3.1 </span>General Terminology</a></li><li class="tocline"><a href="#jsonldprocessor" class="tocxref"><span class="secno">3.2 </span>JsonLdProcessor</a><ul class="toc"><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">3.2.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#callbacks" class="tocxref"><span class="secno">3.3 </span>Callbacks</a><ul class="toc"><li class="tocline"><a href="#jsonldcallback" class="tocxref"><span class="secno">3.3.1 </span>JsonLdCallback</a><ul class="toc"><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">3.3.1.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#quadcallback" class="tocxref"><span class="secno">3.3.2 </span>QuadCallback</a><ul class="toc"><li class="tocline"><a href="#methods-2" class="tocxref"><span class="secno">3.3.2.1 </span>Methods</a></li></ul></li></ul></li><li class="tocline"><a href="#data-structures" class="tocxref"><span class="secno">3.4 </span>Data Structures</a><ul class="toc"><li class="tocline"><a href="#url" class="tocxref"><span class="secno">3.4.1 </span>URL</a></li><li class="tocline"><a href="#jsonldoptions" class="tocxref"><span class="secno">3.4.2 </span>JsonLdOptions</a></li><li class="tocline"><a href="#quad" class="tocxref"><span class="secno">3.4.3 </span>Quad</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">3.4.3.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#node" class="tocxref"><span class="secno">3.4.4 </span>Node</a></li><li class="tocline"><a href="#iri" class="tocxref"><span class="secno">3.4.5 </span><abbr title="Internationalized Resource Identifier">IRI</abbr></a><ul class="toc"><li class="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">3.4.5.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#blank-node" class="tocxref"><span class="secno">3.4.6 </span><span title="blank_node">Blank Node</span></a><ul class="toc"><li class="tocline"><a href="#attributes-2" class="tocxref"><span class="secno">3.4.6.1 </span>Attributes</a></li></ul></li><li class="tocline"><a href="#literal" class="tocxref"><span class="secno">3.4.7 </span>Literal</a><ul class="toc"><li class="tocline"><a href="#attributes-3" class="tocxref"><span class="secno">3.4.7.1 </span>Attributes</a></li></ul></li></ul></li></ul></li><li class="tocline"><a href="#algorithms" class="tocxref"><span class="secno">4. </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#algorithm-terms" class="tocxref"><span class="secno">4.1 </span>Algorithm Terms</a></li><li class="tocline"><a href="#context-processing" class="tocxref"><span class="secno">4.2 </span>Context Processing</a></li><li class="tocline"><a href="#iri-expansion" class="tocxref"><span class="secno">4.3 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</a></li><li class="tocline"><a href="#iri-compaction" class="tocxref"><span class="secno">4.4 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a><ul class="toc"><li class="tocline"><a href="#iri-compaction-algorithm" class="tocxref"><span class="secno">4.4.1 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction Algorithm</a></li><li class="tocline"><a href="#term-rank-algorithm" class="tocxref"><span class="secno">4.4.2 </span>Term Rank Algorithm</a></li></ul></li><li class="tocline"><a href="#value-expansion" class="tocxref"><span class="secno">4.5 </span>Value Expansion</a></li><li class="tocline"><a href="#value-compaction" class="tocxref"><span class="secno">4.6 </span>Value Compaction</a></li><li class="tocline"><a href="#expansion-1" class="tocxref"><span class="secno">4.7 </span>Expansion</a><ul class="toc"><li class="tocline"><a href="#expansion-algorithm" class="tocxref"><span class="secno">4.7.1 </span>Expansion Algorithm</a></li></ul></li><li class="tocline"><a href="#compaction-1" class="tocxref"><span class="secno">4.8 </span>Compaction</a><ul class="toc"><li class="tocline"><a href="#compaction-algorithm" class="tocxref"><span class="secno">4.8.1 </span>Compaction Algorithm</a></li></ul></li><li class="tocline"><a href="#rdf-conversion" class="tocxref"><span class="secno">4.9 </span>RDF Conversion</a><ul class="toc"><li class="tocline"><a href="#overview" class="tocxref"><span class="secno">4.9.1 </span>Overview</a></li><li class="tocline"><a href="#parsing-examples" class="tocxref"><span class="secno">4.9.2 </span>Parsing Examples</a></li><li class="tocline"><a href="#convert-to-rdf-algorithm" class="tocxref"><span class="secno">4.9.3 </span>Convert to RDF Algorithm</a></li><li class="tocline"><a href="#list-conversion" class="tocxref"><span class="secno">4.9.4 </span>List Conversion</a></li><li class="tocline"><a href="#convert-from-rdf-algorithm" class="tocxref"><span class="secno">4.9.5 </span>Convert from RDF Algorithm</a></li></ul></li></ul></li><li class="tocline"><a href="#data-round-tripping" class="tocxref"><span class="secno">5. </span>Data Round Tripping</a></li><li class="tocline"><a href="#appendix-a" class="tocxref"><span class="secno">A. </span>Initial Context</a></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">B. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">C. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">C.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">C.2 </span>Informative references</a></li></ul></li></ul></div>
<div id="preface" class="section">
<!-- OddPage -->
<h2><span class="secno">1. </span>Preface</h2>
<p>
This document is a detailed specification for an Application Programming
Interface for the JSON-LD Syntax. The document is primarily intended for
the following audiences:
</p>
<ul>
<li>Web authors and developers that want a very detailed view of how
a JSON-LD processor and the API operates.</li>
<li>Software developers that want to implement processors and APIs for
JSON-LD.</li>
</ul>
<p>
To understand the basics in this specification you must first be familiar with
JSON, which is detailed in [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC4627">RFC4627</a></cite>]. You must also understand the
JSON-LD Syntax [<cite><a class="bibref" rel="biblioentry" href="#bib-JSON-LD">JSON-LD</a></cite>], which is the base syntax used by all of the
algorithms in this document. To understand the API and how it is
intended to operate in a programming environment, it is useful to have working
knowledge of the JavaScript programming language [<cite><a class="bibref" rel="biblioentry" href="#bib-ECMA-262">ECMA-262</a></cite>] and
WebIDL [<cite><a class="bibref" rel="biblioentry" href="#bib-WEBIDL">WEBIDL</a></cite>]. To understand how JSON-LD maps to RDF, it is helpful to be
familiar with the basic RDF concepts [<cite><a class="bibref" rel="biblioentry" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>].</p>
<div id="contributing" class="section">
<h3><span class="secno">1.1 </span>Contributing</h3>
<p>There are a number of ways that one may participate in the development of
this specification:</p>
<ul>
<li>If you want to make sure that your feedback is formally addressed by
the RDF Working Group, you should send it to public-rdf-comments:
<a href="http://lists.w3.org/Archives/Public/public-rdf-comments/">public-rdf-comments@w3.org</a></li>
<li>Ad-hoc technical discussion primarily occurs on the public community 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 JSON-LD Community Group teleconferences</a>
are held on Tuesdays at 1500UTC every week.</li>
<li>RDF Working Group teleconferences are held on Wednesdays at 1500UTC
every week. Participation is limited to RDF Working Group members.</li>
<li>Specification bugs and issues should be reported in the
<a href="https://github.com/json-ld/json-ld.org/issues">issue tracker</a>
if you do not want to send an e-mail to the public-rdf-comments mailing
list.</li>
<li><a href="https://github.com/json-ld/json-ld.org/tree/master/spec">Source code</a>
for the specification can be found on Github.</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>
</div>
</div>
<div id="introduction" class="section">
<!-- OddPage -->
<h2><span class="secno">2. </span>Introduction</h2>
<p>
The JSON-LD Syntax specification [<cite><a class="bibref" rel="biblioentry" href="#bib-JSON-LD">JSON-LD</a></cite>] outlines a language that may be
used to express Linked Data in JSON. Often, it is useful to be able to
transform JSON-LD documents so that they may be easily processed in
a programming environment like JavaScript, Python or Ruby.
</p>
<p>
There are three major types of transformation that are discussed in this
document; compaction, expansion, and RDF conversion.
</p>
<div id="expansion" class="section">
<h3><span class="secno">2.1 </span>Expansion</h3>
<p>
Software algorithms are easiest to write when the data that they are processing
have a regular form. Since information can be represented by JSON-LD in a
variety of different ways, transforming all of these methods into a uniform
structure allows the developer to simplify their processing code. For example,
note that the following input uses only <a class="tref internalDFN" title="term" href="#dfn-term">term</a>s and is fairly
compact:
</p>
<div class="example"><div class="example-title"><span>Example 1</span></div><pre class="example">var input1 = {
"@context": "http://json-ld.org/contexts/person.jsonld"
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}</pre></div>
<p>
The next input example uses one <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> to express a property, but
leaves the rest of the information untouched.
</p>
<div class="example"><div class="example-title"><span>Example 2</span></div><pre class="example">var input2 = {
"@context": "http://json-ld.org/contexts/person.jsonld"
"<span class="diff">http://xmlns.com/foaf/0.1/name</span>": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}</pre></div>
<p>
While both inputs are valid JSON-LD, writing a program to handle every
permutation of possible inputs can be difficult, especially when the incoming
context could change as well. To ensure that the data can be given a more
uniform structure, JSON-LD introduces the notion of expansion.
<dfn title="expansion" id="dfn-expansion">Expansion</dfn> performs two important operations. The first is to
expand all values that are <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>s to their fully expanded form.
The second is to express all values in <dfn title="expanded_form" id="dfn-expanded_form">expanded form</dfn>. To
transform both inputs above to the same representation, the developer could
do the following:
</p>
<div class="example"><div class="example-title"><span>Example 3</span></div><pre class="example">function expansionCallback(output) {
console.log(output);
}
// the second parameter is 'null' because the developer does not wish to
// inject another context value
jsonld.expand(input1, null, expansionCallback);
jsonld.expand(input2, null, expansionCallback);</pre></div>
<p>
The output for both calls above will be:
</p>
<div class="example"><div class="example-title"><span>Example 4</span></div><pre class="example">[{
"http://xmlns.com/foaf/0.1/name": [{
"@value": "Manu Sporny"
}],
"http://xmlns.com/foaf/0.1/homepage": [{
"@id": "http://manu.sporny.org/"
}]
}]</pre></div>
<p>
Note that in the example above; all <a class="tref internalDFN" title="context" href="#dfn-context">context</a> definitions have
been removed, all <a class="tref internalDFN" title="term" href="#dfn-term">term</a> and prefixes have been expanded to full
IRIs, and all <a class="tref internalDFN" title="literal" href="#dfn-literal">literal</a>s are expressed in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a>.
While the output is more difficult for a human to read, it is easier for a
software program to process because of its very regular structure.
</p>
</div>
<div id="compaction" class="section">
<h3><span class="secno">2.2 </span>Compaction</h3>
<p>
While expansion expands a given input as much as possible, compaction performs
the opposite operation - expressing a given input as succinctly as possible.
While expansion is meant to produce something that is easy to process by
software programs, compaction is meant to produce something that is easy to
ready by software developers. Compaction uses a developer-supplied
<a class="tref internalDFN" title="context" href="#dfn-context">context</a> to compresses all <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>s to <a class="tref internalDFN" title="term" href="#dfn-term">term</a>s
or <a class="tref internalDFN" title="prefix" href="#dfn-prefix">prefix</a>es, and compacts all <a class="tref internalDFN" title="literal" href="#dfn-literal">literal</a>s expressed
in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a> as much as possible.
</p>
<p>
The following example expresses input that has already been fully expanded:
</p>
<div class="example"><div class="example-title"><span>Example 5</span></div><pre class="example">var expandedInput = [{
"http://xmlns.com/foaf/0.1/name": [{
"@value": "Manu Sporny"
}],
"http://xmlns.com/foaf/0.1/homepage": [{
"@id": "http://manu.sporny.org/"
}]
}]</pre></div>
<p>
A developer that wants to transform the data above into a more human-readable
form, could do the following using the JSON-LD API:
</p>
<div class="example"><div class="example-title"><span>Example 6</span></div><pre class="example">function compactionCallback(output) {
console.log(output);
}
jsonld.compact(expandedInput, "http://json-ld.org/contexts/person.jsonld", compactionCallback);</pre></div>
<p>
The following would be the result of the call above:
</p>
<div class="example"><div class="example-title"><span>Example 7</span></div><pre class="example">{
"@context": "http://json-ld.org/contexts/person.jsonld"
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}</pre></div>
<p>
Note that all of the <a class="tref internalDFN" title="term" href="#dfn-term">term</a>s have been compressed and
the <a class="tref internalDFN" title="context" href="#dfn-context">context</a> has been injected into the output. While compacted
output is most useful to humans, it can also be carefully used to generate
structures that are easy to use for developers to program against as well.
</p>
</div>
<div id="conversion-to-and-from-rdf" class="section">
<h3><span class="secno">2.3 </span>Conversion to and from RDF</h3>
<p>
JSON-LD can be used to losslessly express the RDF data model as described in
the RDF Concepts document [<cite><a class="bibref" rel="biblioentry" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>]. This ensures that
data can be round-tripped from any RDF syntax, like N-Triples or TURTLE,
without any loss in the fidelity of the data. Assume the following RDF input
in N-Triples format:
</p>
<div class="example"><div class="example-title"><span>Example 8</span></div><pre class="example">var data = "
<http://manu.sporny.org/about/#manu> <http://xmlns.com/foaf/0.1/name> \"Manu Sporny\" .\n
<http://manu.sporny.org/about/#manu> <http://xmlns.com/foaf/0.1/homepage> <http://manu.sporny.org/> .";</pre></div>
<p>
A developer can use the JSON-LD API to transform the markup above into a
JSON-LD document:
</p>
<div class="example"><div class="example-title"><span>Example 9</span></div><pre class="example">function conversionCallback(result)
{
console.log("JSON-LD Document: ", result);
};
jsonld.fromRDF(data, conversionCallback, {"format": "ntriples"});</pre></div>
<p>
The following expanded output would be the result of the call above:
</p>
<div class="example"><div class="example-title"><span>Example 10</span></div><pre class="example">[{
"@id": "http://manu.sporny.org/about/#manu",
"http://xmlns.com/foaf/0.1/name": [{
"@value": "Manu Sporny"
}],
"http://xmlns.com/foaf/0.1/homepage": [{
"@id": "http://manu.sporny.org/"
}]
}]</pre></div>
<p>
Note that the output above, could easily be compacted to produce the following
using the technique outlined in the previous section:
</p>
<div class="example"><div class="example-title"><span>Example 11</span></div><pre class="example">{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://manu.sporny.org/about/#manu",
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}</pre></div>
<p>
Transforming the object above back to RDF is as simple as calling the
<code>toRDF()</code> method:
</p>
<div class="example"><div class="example-title"><span>Example 12</span></div><pre class="example">var jsonldDocument = ...; // assign the JSON-LD document here
function rdfCallback(quads)
{
console.log("RDF Data: ", quads);
};
jsonld.toRDF(jsonldDocument, rdfCallback);</pre></div>
</div>
<div id="framing-and-normalization" class="section">
<h3><span class="secno">2.4 </span>Framing and Normalization</h3>
<div class="issue"><div class="issue-title"><span>Issue 2</span></div><p class="">
There are currently two other API methods that are in active development and
were not ready for publication at the time this document was published.
Framing allows a developer to force a different layout for the data and
effectively perform query-by-example on JSON-LD documents - this is most
useful when a JSON-LD-based REST API does not know the exact form of the data
it is getting in, but still wants to operate upon it if some bare essentials
are found in the data. JSON-LD normalization allows JSON-LD documents to be
deterministically serialized such that they can be digitally signed or be
used to find the differences between two <a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a>s.
It is expected that framing will be a part of the final API. It is expected
that normalization will be an optional feature that JSON-LD processors may
implement.
</p></div>
</div>
</div>
<div id="the-application-programming-interface" class="section">
<!-- OddPage -->
<h2><span class="secno">3. </span>The Application Programming Interface</h2>
<p>This API provides a clean mechanism that enables developers to convert
JSON-LD data into a a variety of output formats that are easier to work
with in various programming languages. If a JSON-LD API is provided in
a programming environment, the entirety of the following API <em class="rfc2119" title="must">must</em> be
implemented.
</p>
<div id="general-terminology" class="section">
<h3><span class="secno">3.1 </span>General Terminology</h3>
<div class="issue"><div class="issue-title"><span>Issue 3</span></div><p class="">
The intent of the Working Group and the Editors of this specification is to
eventually align terminology used in this document with the terminology used
in the RDF Concepts document to the extent to which it makes sense to do so.
In general, if there is an analogue to terminology used in this document in
the RDF Concepts document, the preference is to use the terminology in the
RDF Concepts document.
</p></div>
<p>
The following is an explanation of the general terminology used in this
document:
</p>
<dl>
<dt><dfn title="json_object" id="dfn-json_object">JSON object</dfn></dt><dd>
An object structure is represented as a pair of curly brackets surrounding zero or
more name-value pairs. A name is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>. A single colon comes after
each name, separating the name from the value. A single comma separates a value
from a following name. The names within an object <em class="rfc2119" title="should">should</em> be unique.
</dd>
<dt><dfn title="array" id="dfn-array">array</dfn></dt>
<dd>
An array is represented as square brackets surrounding zero or more
values that are separated by commas.
</dd>
<dt><dfn title="string" id="dfn-string">string</dfn></dt><dd>
A string is a sequence of zero or more Unicode (UTF-8) characters,
wrapped in double quotes, using backslash escapes (if necessary). A
character is represented as a single character string.
</dd>
<dt><dfn title="number" id="dfn-number">number</dfn></dt>
<dd>
A number is similar to that used in most programming languages, except
that the octal and hexadecimal formats are not used and that leading
zeros are not allowed.</dd>
<dt><dfn title="true" id="dfn-true">true</dfn> and <dfn title="false" id="dfn-false">false</dfn></dt><dd>
Values that are used to express one of two possible boolean states.
</dd>
<dt><dfn title="null" id="dfn-null">null</dfn></dt><dd>
Unless otherwise specified, a JSON-LD processor <em class="rfc2119" title="must">must</em> act as if a
key-value pair in the body of a JSON-LD document was never declared when
the value equals <em>null</em>. If <code>@value</code>,
<code>@list</code>, or <code>@set</code> is set to <em>null</em> in
expanded form, then the entire JSON object is ignored. If
<code>@context</code> is set to <em>null</em>, the
<a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> is reset and when used
within a <a class="tref internalDFN" title="context" href="#dfn-context">context</a>, it removes any definition associated
with the key, unless otherwise specified.
</dd>
<dt><dfn title="subject_definition" id="dfn-subject_definition">subject definition</dfn></dt><dd>
A <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> used to represent a <a class="tref internalDFN" title="subject" href="#dfn-subject">subject</a> and
one or more properties of that subject. A <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> is a
subject definition if it does not contain they keys <code>@value</code>,
<code>@list</code> or <code>@set</code> and it has one or more keys
other than <code>@id</code>.</dd>
<dt><dfn title="subject_reference" id="dfn-subject_reference">subject reference</dfn></dt><dd>
A <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> used to reference a subject having only the
<code>@id</code> key.</dd>
<dt><dfn title="linked_data" id="dfn-linked_data">Linked Data</dfn></dt>
<dd>A set of documents, each containing a representation of a
<a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a>.</dd>
<dt><dfn title="linked_data_graph" id="dfn-linked_data_graph">linked data graph</dfn> or <dfn title="dataset" id="dfn-dataset">dataset</dfn></dt>
<dd>An unordered labeled directed graph, where <a class="tref internalDFN" title="node" href="#dfn-node">node</a>s are
<a class="tref internalDFN" title="subject" href="#dfn-subject">subject</a>s or <a class="tref internalDFN" title="object" href="#dfn-object">object</a>s, and edges are
properties.</dd>
<dt><dfn title="node" id="dfn-node">node</dfn></dt>
<dd>A piece of information that is represented in a
<a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a>.</dd>
<dt><dfn title="named_graph" id="dfn-named_graph">named graph</dfn></dt>
<dd>A <a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a> that has one or more
<a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> that are used to refer to it.</dd>
<dt><dfn title="graph_name" id="dfn-graph_name">graph name</dfn></dt>
<dd>An <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> that is a reference to a
<a class="tref internalDFN" title="named_graph" href="#dfn-named_graph">named graph</a>.</dd>
<dt><dfn title="default_graph" id="dfn-default_graph">default graph</dfn></dt>
<dd>When executing an algorithm, the graph where data should be placed
if a <a class="tref internalDFN" title="named_graph" href="#dfn-named_graph">named graph</a> is not specified.</dd>
<dt><dfn title="subject" id="dfn-subject">subject</dfn></dt>
<dd>Any node in a <a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a> with at least one
outgoing edge.</dd>
<dt><dfn title="iri" id="dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt>
<dd>An Internationalized Resource Identifier as described
in [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC3987">RFC3987</a></cite>]).</dd>
<dt><dfn title="object" id="dfn-object">object</dfn></dt>
<dd>A node in a <a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a> with at least one
incoming edge.</dd>
<dt><dfn title="property" id="dfn-property">property</dfn></dt>
<dd>An edge of the <a class="tref internalDFN" title="linked_data_graph" href="#dfn-linked_data_graph">linked data graph</a>.</dd>
<dt><dfn title="literal" id="dfn-literal">literal</dfn></dt>
<dd>An <a class="tref internalDFN" title="object" href="#dfn-object">object</a> with a label that is not an
<a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
<dt><dfn title="quad" id="dfn-quad">quad</dfn></dt>
<dd>A piece of information that contains four items; a
<a class="tref internalDFN" title="subject" href="#dfn-subject">subject</a>, a <a class="tref internalDFN" title="property" href="#dfn-property">property</a>, a <a class="tref internalDFN" title="object" href="#dfn-object">object</a>,
and a <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.</dd>
<dt><dfn title="context" id="dfn-context">context</dfn></dt>
<dd>A <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> that contains rules for interpreting a
JSON-LD document.</dd>
<dt><dfn title="keyword" id="dfn-keyword">keyword</dfn></dt>
<dd>A JSON key that is specific to JSON-LD, specified in the JSON-LD
Syntax specification [<cite><a class="bibref" rel="biblioentry" href="#bib-JSON-LD">JSON-LD</a></cite>] in the section titled
<a href="http://sites.local/json-ld.org/spec/latest/json-ld-syntax/#syntax-tokens-and-keywords">Syntax Tokens and Keywords</a>.</dd>
</dl>
</div>
<div id="jsonldprocessor" class="section">
<h3><span class="secno">3.2 </span>JsonLdProcessor</h3>
<p>
The JSON-LD Processor interface is the high-level programming structure that
developers use to access the JSON-LD transformation methods.
</p>
<pre class="idl"><span class="idlInterface" id="idl-def-JsonLdProcessor">[<span class="extAttr">NoInterfaceObject</span>]
interface <span class="idlInterfaceID">JsonLdProcessor</span> {
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-expand-void-object-or-object---or-URL-input-object-or-URL-context-JsonLdCallback-callback-JsonLdOptions-options">expand</a></span> (<span class="idlParam"><span class="idlParamType"><a>object or object[] or URL</a></span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType"><a>object or URL</a>?</span> <span class="idlParamName">context</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-compact-void-object-or-object---or-URL-input-object-or-URL-context-JsonLdCallback-callback-JsonLdOptions-options">compact</a></span> (<span class="idlParam"><span class="idlParamType"><a>object or object[] or URL</a></span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType"><a>object or URL</a></span> <span class="idlParamName">context</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-fromRDF-void-QuadArray-input-JsonLdCallback-callback-JsonLdOptions-options">fromRDF</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-Quad" class="idlType"><code>Quad</code></a>[]</span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod"> <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-toRDF-void-object-or-object---or-URL-input-QuadCallback-callback-JsonLdOptions-options">toRDF</a></span> (<span class="idlParam"><span class="idlParamType"><a>object or object[] or URL</a></span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-QuadCallback" class="idlType"><code>QuadCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></span> <span class="idlParamName">options</span></span>);</span>
};</span>
</pre><div id="methods" class="section"><h2><span class="secno">3.2.1 </span>Methods</h2><dl class="methods"><dt id="widl-JsonLdProcessor-compact-void-object-or-object---or-URL-input-object-or-URL-context-JsonLdCallback-callback-JsonLdOptions-options"><code>compact</code></dt><dd>
<a href="#compaction">Compacts</a> the given <code>input</code> using the
<code>context</code> according to the steps in the
<a href="#compaction-algorithm">Compaction Algorithm</a>. The
<code>input</code> <em class="rfc2119" title="must">must</em> be copied, compacted and returned if there are
no errors. If the compaction fails, an appropriate exception <em class="rfc2119" title="must">must</em> be
thrown.
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code><a>object or object[] or URL</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The JSON-LD object or array of JSON-LD objects to perform the compaction upon or an
<a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the JSON-LD document to compact.</td></tr><tr><td class="prmName">context</td><td class="prmType"><code><a>object or URL</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The context to use when compacting the <code>input</code>; either in the
form of an <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> or as <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on
the given <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options that <em class="rfc2119" title="may">may</em> affect the expansion algorithm such as, e.g., the
input document's base <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. This also includes <code>optimize</code>,
which if set will cause processor-specific optimization.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-JsonLdProcessor-expand-void-object-or-object---or-URL-input-object-or-URL-context-JsonLdCallback-callback-JsonLdOptions-options"><code>expand</code></dt><dd>
<a href="#expansion">Expands</a> the given <code>input</code> according to
the steps in the <a href="#expansion-algorithm">Expansion Algorithm</a>. The
<code>input</code> <em class="rfc2119" title="must">must</em> be copied, expanded and returned if there are
no errors. If the expansion fails, an appropriate exception <em class="rfc2119" title="must">must</em> be thrown.
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code><a>object or object[] or URL</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The JSON-LD object or array of JSON-LD objects to perform the expansion upon or an
<a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the JSON-LD document to expand.</td></tr><tr><td class="prmName">context</td><td class="prmType"><code><a>object or URL</a></code></td><td class="prmNullTrue">✔</td><td class="prmOptFalse">✘</td><td class="prmDesc">An optional external context to use additionally to the context embedded in
<code>input</code> when expanding the <code>input</code>.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on
the given <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options that <em class="rfc2119" title="may">may</em> affect the expansion algorithm such as, e.g., the
input document's base <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-JsonLdProcessor-fromRDF-void-QuadArray-input-JsonLdCallback-callback-JsonLdOptions-options"><code>fromRDF</code></dt><dd>Creates a JSON-LD document given an set of <a class="datatype idlType" title="quad" href="#idl-def-quad"><code>Quads</code></a>.
<table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code><a href="#idl-def-Quad" class="idlType"><code>Quad</code></a>[]</code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A <a class="tref internalDFN" title="dataset" href="#dfn-dataset">dataset</a> represented as an array of <a class="datatype idlType" title="quad" href="#idl-def-quad"><code>Quads</code></a>.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on
the given <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options that will affect the algorithm. This includes <code>notType</code>,
which if set to <a class="tref internalDFN" title="true" href="#dfn-true">true</a> causes the resulting document to use <code>rdf:type</code>
as a property, instead of <code>@type</code>.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-JsonLdProcessor-toRDF-void-object-or-object---or-URL-input-QuadCallback-callback-JsonLdOptions-options"><code>toRDF</code></dt><dd>
Processes the <code>input</code> according to the
<a href="#convert-to-rdf-algorithm">Convert to RDF Algorithm</a>, calling
the provided <code>callback</code> for each <a class="datatype idlType" title="Quad" href="#idl-def-Quad"><code>Quad</code></a> generated.