Repository navigation
Expand file tree
/
Copy pathSchemaTest.py
More file actions
57 lines (53 loc) · 1.47 KB
/
Copy pathSchemaTest.py
File metadata and controls
57 lines (53 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
import os
import json
string schemaJson = @"{
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "https://github.com/gabe7murphy/oeda-json/blob/master/Phoenix.Countries.actors.json",
"title": "Phoenix.CountriesActors",
"description": "OEDA dictionary for Countries and Actors",
"type": "array",
"items": {
"$ref": "#/definitions/WelcomeElement"
},
"definitions": {
"WelcomeElement": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
},
"alias": {
"type": "array",
"items": {
"type": "string"
}
},
"codes": {
"type": "array",
"items": {
"type": "string"
}
},
"comments": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"name",
"codes"
],
"title": "WelcomeElement"
}
}
}";
JsonSchema schema = JsonSchema.Parse(schemaJson);
JObject person = JObject.Parse(@"{
'name': 'TRUMP',
'codes': ['USAELI','USAGOV']
}");
bool valid = person.IsValid(schema);