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

Function draft_201909_example

examples/src/jsonschema_examples.cpp:403–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403void draft_201909_example()
404{
405 json schema = json::parse(R"(
406{
407 "$schema": "https://json-schema.org/draft/2019-09/schema",
408 "type": "object",
409 "properties": {
410 "foo": { "type": "string" }
411 },
412 "allOf": [
413 {
414 "properties": {
415 "bar": { "type": "string" }
416 }
417 }
418 ],
419 "unevaluatedProperties": false
420}
421)");
422
423 jsonschema::json_schema<json> compiled = jsonschema::make_json_schema(schema);
424
425 json data = json::parse(R"({"foo": "foo","bar": "bar","baz": "baz"})");
426
427 jsoncons::json_decoder<ojson> decoder;
428 compiled.validate(data, decoder);
429 ojson output = decoder.get_result();
430 std::cout << pretty_print(output) << "\n\n";
431}
432
433void draft_07_example()
434{

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