Go to the documentation of this file.
2#include <nlohmann/json-schema.hpp>
9{
10 "$schema": "http://json-schema.org/draft-07/schema#",
11 "properties": {
12 "width": {
13 "type": "integer"
14 }
15 },
16 "default": {
17 "width": 42
18 }
19})"_json;
29 if (!nul_json.is_null()) {
33 const auto default_patch = validator
.validate(nul_json
);
35 if (default_patch.is_null()) {
36 std::cerr <<
"Patch is null but should contain operation to add defaults to root" << std::endl;
40 const auto actual = nul_json.patch(default_patch);
41 const auto expected = R"({"width": 42})"_json;
42 if (actual != expected) {
43 std::cerr <<
"Patch of defaults is wrong for root schema: '" << actual.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 const json root_default