MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / draft_07_example

Function draft_07_example

examples/src/jsonschema_examples.cpp:433–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433void draft_07_example()
434{
435 json schema = json::parse(R"(
436{
437 "items": [{}],
438 "additionalItems": {"type": "integer"}
439}
440)");
441
442 // Need to supply default version because schema does not have $schema keyword
443 auto options = jsonschema::evaluation_options{}
444 .default_version(jsonschema::schema_version::draft7());
445 auto compiled = jsonschema::make_json_schema(schema, options);
446
447 json data = json::parse(R"([ null, 2, 3, "foo" ])");
448
449 jsoncons::json_decoder<ojson> decoder;
450 compiled.validate(data, decoder);
451 ojson output = decoder.get_result();
452 std::cout << pretty_print(output) << "\n\n";
453}
454
455void cross_schema_example()
456{

Callers 1

mainFunction · 0.85

Calls 5

parseFunction · 0.85
make_json_schemaFunction · 0.85
pretty_printFunction · 0.85
get_resultMethod · 0.80
validateMethod · 0.45

Tested by

no test coverage detected