1#include <nlohmann/json.hpp>
3#include <nlohmann/json-schema.hpp>
10 {
11 "$id": "http://example.com/root.json",
12 "definitions": {
13 "A": { "$id": "#foo" },
14 "B": {
15 "$id": "other.json",
16 "definitions": {
17 "X": { "$id": "#bar" },
18 "Y": { "$id": "t/inner.json" }
19 }
20 },
21 "C": {
22
23 "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f",
24 "definitions": {
25 "Z": { "$id": "#bar" },
26 "9": { "$id": "http://example.com/drole.json" }
27 }
28 }
29 }
30 }
31)"_json;
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
70{
71 "id": "http://localhost:1234/scope_change_defs2.json",
72 "type" : "object",
73 "properties": {
74 "list": {"$ref": "#/definitions/baz/definitions/bar"}
75 },
76 "definitions": {
77 "baz": {
78 "id": "folder/",
79 "definitions": {
80 "bar": {
81 "type": "array",
82 "items": {"$ref": "folderInteger.json"}
83 }
84 }
85 }
86 }
87})"_json;
98 auto id = s.find(
"$id");
100 base_uris.push_back(base_uris.back()
.derive(id.value()
));
102 for (
auto &u : base_uris)
105 for (
auto i = s.begin();
109 switch (i.value().type()) {
110 case json::value_t::object: {
113 for (
auto &ss : subschema_uri)
119 case json::value_t::string:
121 if (i.key() ==
"$ref") {
122 auto id = base_uris.back()
.derive(i.value()
);
142 std::cerr << i.first <<
" " << *i.second <<
"\n";
std::map< nlohmann::json_uri, const json * > schema_store_
std::vector< json > schemas_
void insert_schema(json &s, std::vector< nlohmann::json_uri > base_uris)
std::string to_string() const
static std::string escape(const std::string &)
json_uri derive(const std::string &uri) const
json_uri append(const std::string &field) const