Go to the documentation of this file.
2#include <nlohmann/json-schema.hpp>
9{
10 "$schema": "http://json-schema.org/draft-07/schema#",
11 "type": "object",
12 "oneOf": [
13 {
14 "type": "object",
15 "properties": {
16 "name": {
17 "enum": "foo"
18 },
19 "code": {
20 "const": 1,
21 "default": 1
22 }
23 }
24 },
25 {
26 "type": "object",
27 "properties": {
28 "name": {
29 "enum": "bar"
30 },
31 "code": {
32 "const": 2,
33 "default": 2
34 }
35 }
36 }
37 ]
38})"_json;
51 json data = R"({"name": "bar"})"_json;
53 [
54 {
55 "op": "add",
56 "path": "/code",
57 "value": 2
58 }
59 ]
60 )"_json;
63 if (patch != expected) {
64 std::cerr <<
"Patch contains wrong operation: '" << patch.dump() <<
"' instead of expected '" << expected.dump() <<
"'" << std::endl;
void set_root_schema(const json &)
json_validator(schema_loader=nullptr, format_checker=nullptr, content_checker=nullptr)
json validate(const json &) const
static void loader(const json_uri &uri, json &schema)
static const json default_schema