This repository was archived by the owner on Nov 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathjson-schema-core.html
958 lines (881 loc) · 41.3 KB
/
json-schema-core.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
---
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head profile="http://www.w3.org/2006/03/hcard http://dublincore.org/documents/2008/08/04/dc-html/">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>JSON Schema: core definitions and terminology</title>
<style type="text/css" title="Xml2Rfc (sans serif)">
/*<![CDATA[*/
a {
text-decoration: none;
}
/* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
a.info {
/* This is the key. */
position: relative;
z-index: 24;
text-decoration: none;
}
a.info:hover {
z-index: 25;
color: #FFF; background-color: #900;
}
a.info span { display: none; }
a.info:hover span.info {
/* The span will display just on :hover state. */
display: block;
position: absolute;
font-size: smaller;
top: 2em; left: -5em; width: 15em;
padding: 2px; border: 1px solid #333;
color: #900; background-color: #EEE;
text-align: left;
}
a.smpl {
color: black;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
address {
margin-top: 1em;
margin-left: 2em;
font-style: normal;
}
body {
color: black;
font-family: verdana, helvetica, arial, sans-serif;
font-size: 10pt;
max-width: 55em;
}
cite {
font-style: normal;
}
dd {
margin-right: 2em;
}
dl {
margin-left: 2em;
}
ul.empty {
list-style-type: none;
}
ul.empty li {
margin-top: .5em;
}
dl p {
margin-left: 0em;
}
dt {
margin-top: .5em;
}
h1 {
font-size: 14pt;
line-height: 21pt;
page-break-after: avoid;
}
h1.np {
page-break-before: always;
}
h1 a {
color: #333333;
}
h2 {
font-size: 12pt;
line-height: 15pt;
page-break-after: avoid;
}
h3, h4, h5, h6 {
font-size: 10pt;
page-break-after: avoid;
}
h2 a, h3 a, h4 a, h5 a, h6 a {
color: black;
}
img {
margin-left: 3em;
}
li {
margin-left: 2em;
margin-right: 2em;
}
ol {
margin-left: 2em;
margin-right: 2em;
}
ol p {
margin-left: 0em;
}
p {
margin-left: 2em;
margin-right: 2em;
}
pre {
margin-left: 3em;
background-color: lightyellow;
padding: .25em;
}
pre.text2 {
border-style: dotted;
border-width: 1px;
background-color: #f0f0f0;
width: 69em;
}
pre.inline {
background-color: white;
padding: 0em;
}
pre.text {
border-style: dotted;
border-width: 1px;
background-color: #f8f8f8;
width: 69em;
}
pre.drawing {
border-style: solid;
border-width: 1px;
background-color: #f8f8f8;
padding: 2em;
}
table {
margin-left: 2em;
}
table.tt {
vertical-align: top;
}
table.full {
border-style: outset;
border-width: 1px;
}
table.headers {
border-style: outset;
border-width: 1px;
}
table.tt td {
vertical-align: top;
}
table.full td {
border-style: inset;
border-width: 1px;
}
table.tt th {
vertical-align: top;
}
table.full th {
border-style: inset;
border-width: 1px;
}
table.headers th {
border-style: none none inset none;
border-width: 1px;
}
table.left {
margin-right: auto;
}
table.right {
margin-left: auto;
}
table.center {
margin-left: auto;
margin-right: auto;
}
caption {
caption-side: bottom;
font-weight: bold;
font-size: 9pt;
margin-top: .5em;
}
table.header {
border-spacing: 1px;
width: 95%;
font-size: 10pt;
color: white;
}
td.top {
vertical-align: top;
}
td.topnowrap {
vertical-align: top;
white-space: nowrap;
}
table.header td {
background-color: gray;
width: 50%;
}
table.header a {
color: white;
}
td.reference {
vertical-align: top;
white-space: nowrap;
padding-right: 1em;
}
thead {
display:table-header-group;
}
ul.toc, ul.toc ul {
list-style: none;
margin-left: 1.5em;
margin-right: 0em;
padding-left: 0em;
}
ul.toc li {
line-height: 150%;
font-weight: bold;
font-size: 10pt;
margin-left: 0em;
margin-right: 0em;
}
ul.toc li li {
line-height: normal;
font-weight: normal;
font-size: 9pt;
margin-left: 0em;
margin-right: 0em;
}
li.excluded {
font-size: 0pt;
}
ul p {
margin-left: 0em;
}
.comment {
background-color: yellow;
}
.center {
text-align: center;
}
.error {
color: red;
font-style: italic;
font-weight: bold;
}
.figure {
font-weight: bold;
text-align: center;
font-size: 9pt;
}
.filename {
color: #333333;
font-weight: bold;
font-size: 12pt;
line-height: 21pt;
text-align: center;
}
.fn {
font-weight: bold;
}
.hidden {
display: none;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.title {
color: #990000;
font-size: 18pt;
line-height: 18pt;
font-weight: bold;
text-align: center;
margin-top: 36pt;
}
.vcardline {
display: block;
}
.warning {
font-size: 14pt;
background-color: yellow;
}
@media print {
.noprint {
display: none;
}
a {
color: black;
text-decoration: none;
}
table.header {
width: 90%;
}
td.header {
width: 50%;
color: black;
background-color: white;
vertical-align: top;
font-size: 12pt;
}
ul.toc a::after {
content: leader('.') target-counter(attr(href), page);
}
ul.ind li li a {
content: target-counter(attr(href), page);
}
.print2col {
column-count: 2;
-moz-column-count: 2;
column-fill: auto;
}
}
@page {
@top-left {
content: "Internet-Draft";
}
@top-right {
content: "December 2010";
}
@top-center {
content: "Abbreviated Title";
}
@bottom-left {
content: "Doe";
}
@bottom-center {
content: "Expires June 2011";
}
@bottom-right {
content: "[Page " counter(page) "]";
}
}
@page:first {
@top-left {
content: normal;
}
@top-right {
content: normal;
}
@top-center {
content: normal;
}
}
/*]]>*/
</style>
<link href="#rfc.toc" rel="Contents"/>
<link href="#rfc.section.1" rel="Chapter" title="1 Introduction"/>
<link href="#rfc.section.2" rel="Chapter" title="2 Conventions and Terminology"/>
<link href="#rfc.section.3" rel="Chapter" title="3 Core terminology"/>
<link href="#rfc.section.3.1" rel="Chapter" title="3.1 Property, item"/>
<link href="#rfc.section.3.2" rel="Chapter" title="3.2 JSON Schema, keywords"/>
<link href="#rfc.section.3.3" rel="Chapter" title="3.3 Empty schema"/>
<link href="#rfc.section.3.4" rel="Chapter" title="3.4 Root schema, subschema"/>
<link href="#rfc.section.3.5" rel="Chapter" title="3.5 JSON Schema primitive types"/>
<link href="#rfc.section.3.6" rel="Chapter" title="3.6 JSON value equality"/>
<link href="#rfc.section.3.7" rel="Chapter" title="3.7 Instance"/>
<link href="#rfc.section.4" rel="Chapter" title="4 Overview"/>
<link href="#rfc.section.4.1" rel="Chapter" title="4.1 Validation"/>
<link href="#rfc.section.4.2" rel="Chapter" title="4.2 Hypermedia and linking"/>
<link href="#rfc.section.5" rel="Chapter" title="5 General considerations"/>
<link href="#rfc.section.5.1" rel="Chapter" title="5.1 Applicability to all JSON values"/>
<link href="#rfc.section.5.2" rel="Chapter" title="5.2 Programming language independence"/>
<link href="#rfc.section.5.3" rel="Chapter" title="5.3 JSON Schema and HTTP"/>
<link href="#rfc.section.5.4" rel="Chapter" title="5.4 JSON Schema and other protocols"/>
<link href="#rfc.section.5.5" rel="Chapter" title="5.5 Mathematical integers"/>
<link href="#rfc.section.5.6" rel="Chapter" title="5.6 Extending JSON Schema"/>
<link href="#rfc.section.5.7" rel="Chapter" title="5.7 Security considerations"/>
<link href="#rfc.section.6" rel="Chapter" title="6 The "$schema" keyword"/>
<link href="#rfc.section.6.1" rel="Chapter" title="6.1 Purpose"/>
<link href="#rfc.section.6.2" rel="Chapter" title="6.2 Customization"/>
<link href="#rfc.section.7" rel="Chapter" title="7 URI resolution scopes and dereferencing"/>
<link href="#rfc.section.7.1" rel="Chapter" title="7.1 Definition"/>
<link href="#rfc.section.7.2" rel="Chapter" title="7.2 URI resolution scope alteration with the "id" keyword"/>
<link href="#rfc.section.7.2.1" rel="Chapter" title="7.2.1 Valid values"/>
<link href="#rfc.section.7.2.2" rel="Chapter" title="7.2.2 Usage"/>
<link href="#rfc.section.7.2.3" rel="Chapter" title="7.2.3 Canonical dereferencing and inline dereferencing"/>
<link href="#rfc.section.7.2.4" rel="Chapter" title="7.2.4 Inline dereferencing and fragments"/>
<link href="#rfc.section.7.3" rel="Chapter" title="7.3 Interoperability considerations"/>
<link href="#rfc.section.8" rel="Chapter" title="8 Recommended correlation mechanisms for use with the HTTP protocol"/>
<link href="#rfc.section.8.1" rel="Chapter" title="8.1 Correlation by means of the "Content-Type" header"/>
<link href="#rfc.section.8.2" rel="Chapter" title="8.2 Correlation by means of the "Link" header"/>
<link href="#rfc.section.9" rel="Chapter" title="9 IANA Considerations"/>
<link href="#rfc.references" rel="Chapter" title="10 References"/>
<link href="#rfc.references.1" rel="Chapter" title="10.1 Normative References"/>
<link href="#rfc.references.2" rel="Chapter" title="10.2 Informative References"/>
<link href="#rfc.appendix.A" rel="Chapter" title="A ChangeLog"/>
<link href="#rfc.authors" rel="Chapter"/>
<meta name="generator" content="xml2rfc version 2.5.1 - http://tools.ietf.org/tools/xml2rfc" />
<link rel="schema.dct" href="http://purl.org/dc/terms/" />
<meta name="dct.creator" content="Galiegue, F., Ed., Zyp, K., Ed., and G. Court" />
<meta name="dct.identifier" content="urn:ietf:id:draft-zyp-json-schema-04" />
<meta name="dct.issued" scheme="ISO8601" content="2013" />
<meta name="dct.abstract" content="JSON Schema defines the media type "application/schema+json", a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data. " />
<meta name="description" content="JSON Schema defines the media type "application/schema+json", a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data. " />
{% if jekyll.environment == 'production' and site.google_analytics %}
{% include google-analytics.html %}
{% endif %}
</head>
<body>
<table class="header">
<tbody>
<tr>
<td class="left">Internet Engineering Task Force</td>
<td class="right">F. Galiegue, Ed.</td>
</tr>
<tr>
<td class="left">Internet-Draft</td>
<td class="right"></td>
</tr>
<tr>
<td class="left">Intended status: Informational</td>
<td class="right">K. Zyp, Ed.</td>
</tr>
<tr>
<td class="left">Expires: August 26, 2017</td>
<td class="right">SitePen (USA)</td>
</tr>
<tr>
<td class="left"></td>
<td class="right">G. Court</td>
</tr>
<tr>
<td class="left"></td>
<td class="right">2013</td>
</tr>
</tbody>
</table>
<p class="title">JSON Schema: core definitions and terminology<br />
<span class="filename">draft-zyp-json-schema-04</span></p>
<h1 id="rfc.abstract">
<a href="#rfc.abstract">Abstract</a>
</h1>
<p>JSON Schema defines the media type "application/schema+json", a JSON based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data. </p>
<h1 id="rfc.status">
<a href="#rfc.status">Status of This Memo</a>
</h1>
<p>This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.</p>
<p>Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.</p>
<p>Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."</p>
<p>This Internet-Draft will expire on August 26, 2017.</p>
<h1 id="rfc.copyrightnotice">
<a href="#rfc.copyrightnotice">Copyright Notice</a>
</h1>
<p>Copyright (c) 2013 IETF Trust and the persons identified as the document authors. All rights reserved.</p>
<p>This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.</p>
<hr class="noprint" />
<h1 class="np" id="rfc.toc"><a href="#rfc.toc">Table of Contents</a></h1>
<ul class="toc">
<li>1. <a href="#rfc.section.1">Introduction</a></li>
<li>2. <a href="#rfc.section.2">Conventions and Terminology</a></li>
<li>3. <a href="#rfc.section.3">Core terminology</a></li>
<ul><li>3.1. <a href="#rfc.section.3.1">Property, item</a></li>
<li>3.2. <a href="#rfc.section.3.2">JSON Schema, keywords</a></li>
<li>3.3. <a href="#rfc.section.3.3">Empty schema</a></li>
<li>3.4. <a href="#rfc.section.3.4">Root schema, subschema</a></li>
<li>3.5. <a href="#rfc.section.3.5">JSON Schema primitive types</a></li>
<li>3.6. <a href="#rfc.section.3.6">JSON value equality</a></li>
<li>3.7. <a href="#rfc.section.3.7">Instance</a></li>
</ul><li>4. <a href="#rfc.section.4">Overview</a></li>
<ul><li>4.1. <a href="#rfc.section.4.1">Validation</a></li>
<li>4.2. <a href="#rfc.section.4.2">Hypermedia and linking</a></li>
</ul><li>5. <a href="#rfc.section.5">General considerations</a></li>
<ul><li>5.1. <a href="#rfc.section.5.1">Applicability to all JSON values</a></li>
<li>5.2. <a href="#rfc.section.5.2">Programming language independence</a></li>
<li>5.3. <a href="#rfc.section.5.3">JSON Schema and HTTP</a></li>
<li>5.4. <a href="#rfc.section.5.4">JSON Schema and other protocols</a></li>
<li>5.5. <a href="#rfc.section.5.5">Mathematical integers</a></li>
<li>5.6. <a href="#rfc.section.5.6">Extending JSON Schema</a></li>
<li>5.7. <a href="#rfc.section.5.7">Security considerations</a></li>
</ul><li>6. <a href="#rfc.section.6">The "$schema" keyword</a></li>
<ul><li>6.1. <a href="#rfc.section.6.1">Purpose</a></li>
<li>6.2. <a href="#rfc.section.6.2">Customization</a></li>
</ul><li>7. <a href="#rfc.section.7">URI resolution scopes and dereferencing</a></li>
<ul><li>7.1. <a href="#rfc.section.7.1">Definition</a></li>
<li>7.2. <a href="#rfc.section.7.2">URI resolution scope alteration with the "id" keyword</a></li>
<ul><li>7.2.1. <a href="#rfc.section.7.2.1">Valid values</a></li>
<li>7.2.2. <a href="#rfc.section.7.2.2">Usage</a></li>
<li>7.2.3. <a href="#rfc.section.7.2.3">Canonical dereferencing and inline dereferencing</a></li>
<li>7.2.4. <a href="#rfc.section.7.2.4">Inline dereferencing and fragments</a></li>
</ul><li>7.3. <a href="#rfc.section.7.3">Interoperability considerations</a></li>
</ul><li>8. <a href="#rfc.section.8">Recommended correlation mechanisms for use with the HTTP protocol</a></li>
<ul><li>8.1. <a href="#rfc.section.8.1">Correlation by means of the "Content-Type" header</a></li>
<li>8.2. <a href="#rfc.section.8.2">Correlation by means of the "Link" header</a></li>
</ul><li>9. <a href="#rfc.section.9">IANA Considerations</a></li>
<li>10. <a href="#rfc.references">References</a></li>
<ul><li>10.1. <a href="#rfc.references.1">Normative References</a></li>
<li>10.2. <a href="#rfc.references.2">Informative References</a></li>
</ul><li>Appendix A. <a href="#rfc.appendix.A">ChangeLog</a></li>
<li><a href="#rfc.authors">Authors' Addresses</a></li>
</ul>
<h1 id="rfc.section.1"><a href="#rfc.section.1">1.</a> Introduction</h1>
<p id="rfc.section.1.p.1">JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data. </p>
<p id="rfc.section.1.p.2">This specification defines JSON Schema core terminology and mechanisms; related specifications build upon this specification and define different applications of JSON Schema. </p>
<h1 id="rfc.section.2"><a href="#rfc.section.2">2.</a> Conventions and Terminology</h1>
<p id="rfc.section.2.p.1">The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <a href="#RFC2119">RFC 2119</a> <cite title="NONE">[RFC2119]</cite>. </p>
<p id="rfc.section.2.p.2">The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", "number", "string", "boolean", "true", "false", and "null" in this document are to be interpreted as defined in <a href="#RFC4627">RFC 4627</a> <cite title="NONE">[RFC4627]</cite>. </p>
<h1 id="rfc.section.3"><a href="#rfc.section.3">3.</a> Core terminology</h1>
<h1 id="rfc.section.3.1"><a href="#rfc.section.3.1">3.1.</a> Property, item</h1>
<p id="rfc.section.3.1.p.1">When refering to a JSON Object, as defined by <a href="#RFC4627">[RFC4627]</a>, the terms "member" and "property" may be used interchangeably. </p>
<p id="rfc.section.3.1.p.2">When refering to a JSON Array, as defined by <a href="#RFC4627">[RFC4627]</a>, the terms "element" and "item" may be used interchangeably. </p>
<h1 id="rfc.section.3.2"><a href="#rfc.section.3.2">3.2.</a> JSON Schema, keywords</h1>
<p id="rfc.section.3.2.p.1">A JSON Schema is a JSON document, and that document MUST be an object. Object members (or properties) defined by JSON Schema (this specification, or related specifications) are called keywords, or schema keywords. </p>
<p id="rfc.section.3.2.p.2">A JSON Schema MAY contain properties which are not schema keywords. </p>
<h1 id="rfc.section.3.3"><a href="#rfc.section.3.3">3.3.</a> Empty schema</h1>
<p id="rfc.section.3.3.p.1">An empty schema is a JSON Schema with no properties, or with properties which are not schema keywords. </p>
<h1 id="rfc.section.3.4"><a href="#rfc.section.3.4">3.4.</a> Root schema, subschema</h1>
<p id="rfc.section.3.4.p.1">This example of a JSON Schema has no subschemas: </p>
<pre>
{
"title": "root"
}
</pre>
<p id="rfc.section.3.4.p.2">JSON Schemas can also be nested, as in this example: </p>
<pre>
{
"title": "root",
"otherSchema": {
"title": "nested",
"anotherSchema": {
"title": "alsoNested"
}
}
}
</pre>
<p id="rfc.section.3.4.p.3">In this example, "nested" and "alsoNested" are subschemas, and "root" is a root schema. </p>
<h1 id="rfc.section.3.5"><a href="#rfc.section.3.5">3.5.</a> JSON Schema primitive types</h1>
<p id="rfc.section.3.5.p.1">JSON Schema defines seven primitive types for JSON values: </p>
<dl>
<dt>array</dt>
<dd style="margin-left: 8">A JSON array.</dd>
<dt>boolean</dt>
<dd style="margin-left: 8">A JSON boolean.</dd>
<dt>integer</dt>
<dd style="margin-left: 8">A JSON number without a fraction or exponent part.</dd>
<dt>number</dt>
<dd style="margin-left: 8">Any JSON number. Number includes integer.</dd>
<dt>null</dt>
<dd style="margin-left: 8">The JSON null value.</dd>
<dt>object</dt>
<dd style="margin-left: 8">A JSON object.</dd>
<dt>string</dt>
<dd style="margin-left: 8">A JSON string.</dd>
</dl>
<p> </p>
<h1 id="rfc.section.3.6"><a href="#rfc.section.3.6">3.6.</a> JSON value equality</h1>
<p id="rfc.section.3.6.p.1">Two JSON values are said to be equal if and only if: </p>
<ul class="empty">
<li>both are nulls; or</li>
<li>both are booleans, and have the same value; or</li>
<li>both are strings, and have the same value; or</li>
<li>both are numbers, and have the same mathematical value; or</li>
<li>both are arrays, and: <ul class="empty"><li>have the same number of items; and</li><li>items at the same index are equal according to this definition; or</li></ul><p> </p></li>
<li>both are objects, and: <ul class="empty"><li>have the same set of property names; and</li><li>values for a same property name are equal according to this definition.</li></ul><p> </p></li>
</ul>
<p> </p>
<h1 id="rfc.section.3.7"><a href="#rfc.section.3.7">3.7.</a> Instance</h1>
<p id="rfc.section.3.7.p.1">An instance is any JSON value. An instance may be described by one or more schemas. </p>
<p id="rfc.section.3.7.p.2">An instance may also be referred to as "JSON instance", or "JSON data". </p>
<h1 id="rfc.section.4"><a href="#rfc.section.4">4.</a> Overview</h1>
<p id="rfc.section.4.p.1">This document proposes a new media type "application/schema+json" to identify JSON Schema for describing JSON data. JSON Schemas are themselves written in JSON. This, and related specifications, define keywords allowing to describe this data in terms of allowable values, textual descriptions and interpreting relations with other resources. The following sections are a summary of features defined by related specifications. </p>
<h1 id="rfc.section.4.1"><a href="#rfc.section.4.1">4.1.</a> Validation</h1>
<p id="rfc.section.4.1.p.1">JSON Schema allows applications to validate instances, either non interactively or interactively. For instance, an application may collect JSON data and check that this data matches a given set of constraints; another application may use a JSON Schema to build an interactive interface in order to collect user input according to constraints described by JSON Schema. </p>
<h1 id="rfc.section.4.2"><a href="#rfc.section.4.2">4.2.</a> Hypermedia and linking</h1>
<p id="rfc.section.4.2.p.1">JSON Schema provides a method for extracting link relations from instances to other resources, as well as describing interpretations of instances as multimedia data. This allows JSON data to be interpreted as rich hypermedia documents, placed in the context of a larger set of related resources. </p>
<h1 id="rfc.section.5"><a href="#rfc.section.5">5.</a> General considerations</h1>
<h1 id="rfc.section.5.1"><a href="#rfc.section.5.1">5.1.</a> Applicability to all JSON values</h1>
<p id="rfc.section.5.1.p.1">It is acknowledged that an instance may be any valid JSON value as defined by <a href="#RFC4627">[RFC4627]</a>. As such, JSON Schema does not mandate that an instance be of a particular type: JSON Schema can describe any JSON value, including null. </p>
<h1 id="rfc.section.5.2"><a href="#rfc.section.5.2">5.2.</a> Programming language independence</h1>
<p id="rfc.section.5.2.p.1">JSON Schema is programming language agnostic. The only limitations are the ones expressed by <a href="#RFC4627">[RFC4627]</a> and those of the host programming language. </p>
<h1 id="rfc.section.5.3"><a href="#rfc.section.5.3">5.3.</a> JSON Schema and HTTP</h1>
<p id="rfc.section.5.3.p.1">This specification acknowledges the role of <a href="#RFC2616">HTTP</a> <cite title="NONE">[RFC2616]</cite> as the dominant protocol in use on the Internet, and the wealth of official specifications related to it. </p>
<p id="rfc.section.5.3.p.2">This specification uses a subset of these specifications to recommend a set of mechanisms, usable by this protocol, to associate JSON instances to one or more schemas. </p>
<h1 id="rfc.section.5.4"><a href="#rfc.section.5.4">5.4.</a> JSON Schema and other protocols</h1>
<p id="rfc.section.5.4.p.1">JSON Schema does not define any semantics for the client-server interface for any other protocols than HTTP. These semantics are application dependent, or subject to agreement between the parties involved in the use of JSON Schema for their own needs. </p>
<h1 id="rfc.section.5.5"><a href="#rfc.section.5.5">5.5.</a> Mathematical integers</h1>
<p id="rfc.section.5.5.p.1">It is acknowledged by this specification that some programming languages, and their associated parsers, use different internal representations for floating point numbers and integers, while others do not. </p>
<p id="rfc.section.5.5.p.2">As a consequence, for interoperability reasons, JSON values used in the context of JSON Schema, whether that JSON be a JSON Schema or an instance, SHOULD ensure that mathematical integers be represented as integers as defined by this specification. </p>
<h1 id="rfc.section.5.6"><a href="#rfc.section.5.6">5.6.</a> Extending JSON Schema</h1>
<p id="rfc.section.5.6.p.1">Implementations MAY choose to define additional keywords to JSON Schema. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords to be supported by peer implementations. Implementations SHOULD ignore keywords they do not support. </p>
<h1 id="rfc.section.5.7"><a href="#rfc.section.5.7">5.7.</a> Security considerations</h1>
<p id="rfc.section.5.7.p.1">Both schemas and instances are JSON values. As such, all security considerations defined in <a href="#RFC4627">RFC 4627</a> <cite title="NONE">[RFC4627]</cite> apply. </p>
<h1 id="rfc.section.6"><a href="#rfc.section.6">6.</a> The "$schema" keyword</h1>
<h1 id="rfc.section.6.1"><a href="#rfc.section.6.1">6.1.</a> Purpose</h1>
<p id="rfc.section.6.1.p.1">The "$schema" keyword is both used as a JSON Schema version identifier and the location of a resource which is itself a JSON Schema, which describes any schema written for this particular version. </p>
<p id="rfc.section.6.1.p.2">This keyword MUST be located at the root of a JSON Schema. The value of this keyword MUST be a <a href="#RFC3986">URI</a> <cite title="NONE">[RFC3986]</cite> and a valid <a href="#json-reference">JSON Reference</a> <cite title="NONE">[json-reference]</cite>; this URI MUST be both absolute and normalized. The resource located at this URI MUST successfully describe itself. It is RECOMMENDED that schema authors include this keyword in their schemas. </p>
<p id="rfc.section.6.1.p.3">The following values are predefined: </p>
<dl>
<dt>http://json-schema.org/schema#</dt>
<dd style="margin-left: 8">JSON Schema written against the current version of the specification.</dd>
<dt>http://json-schema.org/hyper-schema#</dt>
<dd style="margin-left: 8">JSON Schema written against the current version of the specification.</dd>
<dt>http://json-schema.org/draft-04/schema#</dt>
<dd style="margin-left: 8">JSON Schema written against this version.</dd>
<dt>http://json-schema.org/draft-04/hyper-schema#</dt>
<dd style="margin-left: 8">JSON Schema hyperschema written against this version.</dd>
<dt>http://json-schema.org/draft-03/schema#</dt>
<dd style="margin-left: 8">JSON Schema written against <a href="#json-schema-03">JSON Schema, draft v3</a> <cite title="NONE">[json-schema-03]</cite>.</dd>
<dt>http://json-schema.org/draft-03/hyper-schema#</dt>
<dd style="margin-left: 8">JSON Schema hyperschema written against <a href="#json-schema-03">JSON Schema, draft v3</a> <cite title="NONE">[json-schema-03]</cite>.</dd>
</dl>
<p> </p>
<h1 id="rfc.section.6.2"><a href="#rfc.section.6.2">6.2.</a> Customization</h1>
<p id="rfc.section.6.2.p.1">When extending JSON Schema with custom keywords, schema authors SHOULD define a custom URI for "$schema". This custom URI MUST NOT be one of the predefined values. </p>
<h1 id="rfc.section.7"><a href="#rfc.section.7">7.</a> URI resolution scopes and dereferencing</h1>
<h1 id="rfc.section.7.1"><a href="#rfc.section.7.1">7.1.</a> Definition</h1>
<p id="rfc.section.7.1.p.1">JSON Schema uses <a href="#json-reference">JSON Reference</a> <cite title="NONE">[json-reference]</cite> as a mechanism for schema addressing. It extends this specification in two ways: </p>
<ul class="empty">
<li>JSON Schema offers facilities to alter the base URI against which a reference must resolve by the means of the "id" keyword;</li>
<li>it defines a specific dereferencing mechanism extending JSON Reference to accept arbitrary fragment parts.</li>
</ul>
<p> </p>
<p id="rfc.section.7.1.p.2">Altering the URI within a schema is called defining a new resolution scope. The initial resolution scope of a schema is the URI of the schema itself, if any, or the empty URI if the schema was not loaded from a URI. </p>
<h1 id="rfc.section.7.2"><a href="#rfc.section.7.2">7.2.</a> URI resolution scope alteration with the "id" keyword</h1>
<h1 id="rfc.section.7.2.1"><a href="#rfc.section.7.2.1">7.2.1.</a> Valid values</h1>
<p id="rfc.section.7.2.1.p.1">The value for this keyword MUST be a string, and MUST be a valid URI. This URI MUST be normalized, and SHOULD NOT be an empty fragment (#) or the empty URI. </p>
<h1 id="rfc.section.7.2.2"><a href="#rfc.section.7.2.2">7.2.2.</a> Usage</h1>
<p id="rfc.section.7.2.2.p.1">The "id" keyword (or "id", for short) is used to alter the resolution scope. When an id is encountered, an implementation MUST resolve this id against the most immediate parent scope. The resolved URI will be the new resolution scope for this subschema and all its children, until another id is encountered. </p>
<p id="rfc.section.7.2.2.p.2">When using "id" to alter resolution scopes, schema authors SHOULD ensure that resolution scopes are unique within the schema. </p>
<p id="rfc.section.7.2.2.p.3">This schema will be taken as an example: </p>
<pre>
{
"id": "http://x.y.z/rootschema.json#",
"schema1": {
"id": "#foo"
},
"schema2": {
"id": "otherschema.json",
"nested": {
"id": "#bar"
},
"alsonested": {
"id": "t/inner.json#a"
}
},
"schema3": {
"id": "some://where.else/completely#"
}
}
</pre>
<p id="rfc.section.7.2.2.p.4">Subschemas at the following URI-encoded <a href="#json-pointer">JSON Pointer</a> <cite title="NONE">[json-pointer]</cite>s (starting from the root schema) define the following resolution scopes: </p>
<dl>
<dt># (document root)</dt>
<dd style="margin-left: 8">http://x.y.z/rootschema.json#</dd>
<dt>#/schema1</dt>
<dd style="margin-left: 8">http://x.y.z/rootschema.json#foo</dd>
<dt>#/schema2</dt>
<dd style="margin-left: 8">http://x.y.z/otherschema.json#</dd>
<dt>#/schema2/nested</dt>
<dd style="margin-left: 8">http://x.y.z/otherschema.json#bar</dd>
<dt>#/schema2/alsonested</dt>
<dd style="margin-left: 8">http://x.y.z/t/inner.json#a</dd>
<dt>#/schema3</dt>
<dd style="margin-left: 8">some://where.else/completely#</dd>
</dl>
<p> </p>
<h1 id="rfc.section.7.2.3"><a href="#rfc.section.7.2.3">7.2.3.</a> Canonical dereferencing and inline dereferencing</h1>
<p id="rfc.section.7.2.3.p.1">When resolving a URI against a resolution scope, an implementation may choose two modes of operation: </p>
<dl>
<dt>canonical dereferencing</dt>
<dd style="margin-left: 8">The implementation dereferences all resolved URIs.</dd>
<dt>inline dereferencing</dt>
<dd style="margin-left: 8">The implementation chooses to dereference URIs within the schema.</dd>
</dl>
<p> </p>
<p id="rfc.section.7.2.3.p.2">Implementations MUST support canonical dereferencing, and MAY support inline dereferencing. </p>
<p id="rfc.section.7.2.3.p.3">For example, consider this schema: </p>
<pre>
{
"id": "http://my.site/myschema#",
"definitions": {
"schema1": {
"id": "schema1",
"type": "integer"
},
"schema2", {
"type": "array",
"items": { "$ref": "schema1" }
}
}
}
</pre>
<p id="rfc.section.7.2.3.p.4">When an implementation encounters the "schema1" reference, it resolves it against the most immediate parent scope, leading to URI "http://my.site/schema1#". The way to process this URI will differ according to the chosen dereferencing mode: </p>
<ul class="empty">
<li>if canonical dereferencing is used, the implementation will dereference this URI, and fetch the content at this URI;</li>
<li>if inline dereferencing is used, the implementation will notice that URI scope "http://my.site/schema1#" is already defined within the schema, and choose to use the appropriate subschema.</li>
</ul>
<p> </p>
<h1 id="rfc.section.7.2.4"><a href="#rfc.section.7.2.4">7.2.4.</a> Inline dereferencing and fragments</h1>
<p id="rfc.section.7.2.4.p.1">When using inline dereferencing, a resolution scope may lead to a URI which has a non empty fragment part which is not a JSON Pointer, as in this example: </p>
<pre>
{
"id": "http://some.site/schema#",
"not": { "$ref": "#inner" },
"definitions": {
"schema1": {
"id": "#inner",
"type": "boolean"
}
}
}
</pre>
<p id="rfc.section.7.2.4.p.2">An implementation choosing to support inline dereferencing SHOULD be able to use this kind of reference. Implementations choosing to use canonical dereferencing, however, are not required to support it. </p>
<h1 id="rfc.section.7.3"><a href="#rfc.section.7.3">7.3.</a> Interoperability considerations</h1>
<p id="rfc.section.7.3.p.1">Inline dereferencing can produce canonical URIs which differ from the canonical URI of the root schema. Schema authors SHOULD ensure that implementations using canonical dereferencing obtain the same content as implementations using inline dereferencing. </p>
<p id="rfc.section.7.3.p.2">Extended JSON References using fragments which are not JSON Pointers are not dereferenceable by implementations choosing not to support inline dereferencing. This kind of reference is defined for backwards compatibility, and SHOULD NOT be used in new schemas. </p>
<h1 id="rfc.section.8"><a href="#rfc.section.8">8.</a> Recommended correlation mechanisms for use with the HTTP protocol</h1>
<p id="rfc.section.8.p.1">It is acknowledged by this specification that the majority of interactive JSON Schema processing will be over HTTP. This section therefore gives recommendations for materializing an instance/schema correlation using mechanisms currently available for this protocol. An instance is said to be described by one (or more) schema(s). </p>
<h1 id="rfc.section.8.1"><a href="#rfc.section.8.1">8.1.</a> Correlation by means of the "Content-Type" header</h1>
<p id="rfc.section.8.1.p.1">It is RECOMMENDED that a MIME type parameter by the name of "profile" be appended to the "Content-Type" header of the instance being processed. If present, the value of this parameter MUST be a valid URI, and this URI SHOULD resolve to a valid JSON Schema. The MIME type MUST be "application/json", or any other subtype. </p>
<p id="rfc.section.8.1.p.2">An example of such a header would be: </p>
<pre>
Content-Type: application/my-media-type+json;
profile=http://example.com/my-hyper-schema#
</pre>
<h1 id="rfc.section.8.2"><a href="#rfc.section.8.2">8.2.</a> Correlation by means of the "Link" header</h1>
<p id="rfc.section.8.2.p.1">When using the "Link" header, the relation type used MUST be "describedBy", as defined by <a href="#RFC5988">RFC 5988, section 5.3</a> <cite title="NONE">[RFC5988]</cite>. The target URI of the "Link" header MUST be a valid JSON Schema. </p>
<p id="rfc.section.8.2.p.2">An example of such a header would be: </p>
<pre>
Link: <http://example.com/my-hyper-schema#>; rel="describedBy"
</pre>
<h1 id="rfc.section.9"><a href="#rfc.section.9">9.</a> IANA Considerations</h1>
<p id="rfc.section.9.p.1">The proposed MIME media type for JSON Schema is defined as follows: </p>
<ul class="empty">
<li>type name: application;</li>
<li>subtype name: schema+json.</li>
</ul>
<p> </p>
<h1 id="rfc.references"><a href="#rfc.references">10.</a> References</h1>
<h1 id="rfc.references.1"><a href="#rfc.references.1">10.1.</a> Normative References</h1>
<table>
<tbody>
<tr>
<td class="reference">
<b id="RFC2119">[RFC2119]</b>
</td>
<td class="top"><a>Bradner, S.</a>, "<a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.</td>
</tr>
</tbody>
</table>
<h1 id="rfc.references.2"><a href="#rfc.references.2">10.2.</a> Informative References</h1>
<table>
<tbody>
<tr>
<td class="reference">
<b id="RFC2616">[RFC2616]</b>
</td>
<td class="top"><a>Fielding, R.</a>, <a>Gettys, J.</a>, <a>Mogul, J.</a>, <a>Frystyk, H.</a>, <a>Masinter, L.</a>, <a>Leach, P.</a> and <a>T. Berners-Lee</a>, "<a href="http://tools.ietf.org/html/rfc2616">Hypertext Transfer Protocol -- HTTP/1.1</a>", RFC 2616, DOI 10.17487/RFC2616, June 1999.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC3986">[RFC3986]</b>
</td>
<td class="top"><a>Berners-Lee, T.</a>, <a>Fielding, R.</a> and <a>L. Masinter</a>, "<a href="http://tools.ietf.org/html/rfc3986">Uniform Resource Identifier (URI): Generic Syntax</a>", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC4627">[RFC4627]</b>
</td>
<td class="top"><a>Crockford, D.</a>, "<a href="http://tools.ietf.org/html/rfc4627">The application/json Media Type for JavaScript Object Notation (JSON)</a>", RFC 4627, DOI 10.17487/RFC4627, July 2006.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC5988">[RFC5988]</b>
</td>
<td class="top"><a>Nottingham, M.</a>, "<a href="http://tools.ietf.org/html/rfc5988">Web Linking</a>", RFC 5988, DOI 10.17487/RFC5988, October 2010.</td>
</tr>
<tr>
<td class="reference">
<b id="json-reference">[json-reference]</b>
</td>
<td class="top"><a title="ForgeRock US, Inc.">Bryan, P.</a> and <a title="SitePen (USA)">K. Zyp</a>, "<a href="http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03">JSON Reference (work in progress)</a>", September 2012.</td>
</tr>
<tr>
<td class="reference">
<b id="json-pointer">[json-pointer]</b>
</td>
<td class="top"><a title="ForgeRock US, Inc.">Bryan, P.</a> and <a title="SitePen (USA)">K. Zyp</a>, "<a href="http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07">JSON Pointer (work in progress)</a>", September 2012.</td>
</tr>
<tr>
<td class="reference">
<b id="json-schema-03">[json-schema-03]</b>
</td>
<td class="top"><a>Court, G.</a> and <a title="SitePen (USA)">K. Zyp</a>, "<a href="http://tools.ietf.org/html/draft-zyp-json-schema-03">JSON Schema, draft 3</a>", September 2012.</td>
</tr>
</tbody>
</table>
<h1 id="rfc.appendix.A"><a href="#rfc.appendix.A">Appendix A.</a> ChangeLog</h1>
<p/>
<dl>
<dt>draft-00</dt>
<dd style="margin-left: 8">
<ul>
<li>Initial draft.</li>
<li>Salvaged from draft v3.</li>
<li>Mandate the use of JSON Reference, JSON Pointer.</li>
<li>Define the role of "id". Define URI resolution scope.</li>
<li>Add interoperability considerations.</li>
</ul>
<p> </p>
</dd>
</dl>
<p> </p>
<h1 id="rfc.authors">
<a href="#rfc.authors">Authors' Addresses</a>
</h1>
<div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Francis Galiegue</span> (editor)
<span class="n hidden">
<span class="family-name">Galiegue</span>
</span>
</span>
<span class="org vcardline"></span>
<span class="adr">
<span class="vcardline">
<span class="locality"></span>
<span class="region"></span>
<span class="code"></span>
</span>
<span class="country-name vcardline"></span>
</span>
<span class="vcardline">EMail: <a href="mailto:[email protected]">[email protected]</a></span>
</address>
</div><div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Kris Zyp</span> (editor)
<span class="n hidden">
<span class="family-name">Zyp</span>
</span>
</span>
<span class="org vcardline">SitePen (USA)</span>
<span class="adr">
<span class="vcardline">530 Lytton Avenue</span>
<span class="vcardline">
<span class="locality">Palo Alto, CA 94301</span>,
<span class="region"></span>
<span class="code"></span>
</span>
<span class="country-name vcardline">USA</span>
</span>
<span class="vcardline">Phone: +1 650 968 8787</span>
<span class="vcardline">EMail: <a href="mailto:[email protected]">[email protected]</a></span>
</address>
</div><div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Gary Court</span>
<span class="n hidden">
<span class="family-name">Court</span>
</span>
</span>
<span class="org vcardline"></span>
<span class="adr">
<span class="vcardline">
<span class="locality">Calgary, AB</span>,
<span class="region"></span>
<span class="code"></span>
</span>
<span class="country-name vcardline">Canada</span>
</span>
<span class="vcardline">EMail: <a href="mailto:[email protected]">[email protected]</a></span>
</address>
</div>
</body>
</html>