JSON Schema examples

Address

schema
1
{
2
"$id": "https://example.com/address.schema.json",
3
"$schema": "https://json-schema.org/draft/2020-12/schema",
4
"description": "An address similar to http://microformats.org/wiki/h-card",
5
"type": "object",
6
"properties": {
7
"post-office-box": {
8
"type": "string"
9
},
10
"extended-address": {
11
"type": "string"
12
},
13
"street-address": {
14
"type": "string"
15
},
16
"locality": {
17
"type": "string"
18
},
19
"region": {
20
"type": "string"
21
},
22
"postal-code": {
23
"type": "string"
24
},
25
"country-name": {
26
"type": "string"
27
}
28
},
29
"required": [ "locality", "region", "country-name" ],
30
"dependentRequired": {
31
"post-office-box": [ "street-address" ],
32
"extended-address": [ "street-address" ]
33
}
34
}

Calendar

schema
1
{
2
"$id": "https://example.com/calendar.schema.json",
3
"$schema": "https://json-schema.org/draft/2020-12/schema",
4
"description": "A representation of an event",
5
"type": "object",
6
"required": [ "dtstart", "summary" ],
7
"properties": {
8
"dtstart": {
9
"type": "string",
10
"description": "Event starting time"
11
},
12
"dtend": {
13
"type": "string",
14
"description": "Event ending time"
15
},
16
"summary": {
17
"type": "string"
18
},
19
"location": {
20
"type": "string"
21
},
22
"url": {
23
"type": "string"
24
},
25
"duration": {
26
"type": "string",
27
"description": "Event duration"
28
},
29
"rdate": {
30
"type": "string",
31
"description": "Recurrence date"
32
},
33
"rrule": {
34
"type": "string",
35
"description": "Recurrence rule"
36
},
37
"category": {
38
"type": "string"
39
},
40
"description": {
41
"type": "string"
42
},
43
"geo": {
44
"$ref": "https://example.com/geographical-location.schema.json"
45
}
46
}
47
}

Card

schema
1
{
2
"$id": "https://example.com/card.schema.json",
3
"$schema": "https://json-schema.org/draft/2020-12/schema",
4
"description": "A representation of a person, company, organization, or place",
5
"type": "object",
6
"required": [ "familyName", "givenName" ],
7
"properties": {
8
"fn": {
9
"description": "Formatted Name",
10
"type": "string"
11
},
12
"familyName": {
13
"type": "string"
14
},
15
"givenName": {
16
"type": "string"
17
},
18
"additionalName": {
19
"type": "array",
20
"items": {
21
"type": "string"
22
}
23
},
24
"honorificPrefix": {
25
"type": "array",
26
"items": {
27
"type": "string"
28
}
29
},
30
"honorificSuffix": {
31
"type": "array",
32
"items": {
33
"type": "string"
34
}
35
},
36
"nickname": {
37
"type": "string"
38
},
39
"url": {
40
"type": "string"
41
},
42
"email": {
43
"type": "object",
44
"properties": {
45
"type": {
46
"type": "string"
47
},
48
"value": {
49
"type": "string"
50
}
51
}
52
},
53
"tel": {
54
"type": "object",
55
"properties": {
56
"type": {
57
"type": "string"
58
},
59
"value": {
60
"type": "string"
61
}
62
}
63
},
64
"adr": { "$ref": "https://example.com/address.schema.json" },
65
"geo": { "$ref": "https://example.com/geographical-location.schema.json" },
66
"tz": {
67
"type": "string"
68
},
69
"photo": {
70
"type": "string"
71
},
72
"logo": {
73
"type": "string"
74
},
75
"sound": {
76
"type": "string"
77
},
78
"bday": {
79
"type": "string"
80
},
81
"title": {
82
"type": "string"
83
},
84
"role": {
85
"type": "string"
86
},
87
"org": {
88
"type": "object",
89
"properties": {
90
"organizationName": {
91
"type": "string"
92
},
93
"organizationUnit": {
94
"type": "string"
95
}
96
}
97
}
98
}
99
}

Geographical location

schema
1
{
2
"$id": "https://example.com/geographical-location.schema.json",
3
"$schema": "https://json-schema.org/draft/2020-12/schema",
4
"title": "Longitude and Latitude Values",
5
"description": "A geographical coordinate.",
6
"required": [ "latitude", "longitude" ],
7
"type": "object",
8
"properties": {
9
"latitude": {
10
"type": "number",
11
"minimum": -90,
12
"maximum": 90
13
},
14
"longitude": {
15
"type": "number",
16
"minimum": -180,
17
"maximum": 180
18
}
19
}
20
}