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

Function validate_three_ways

examples/src/jsonschema_examples.cpp:21–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace jsonpatch = jsoncons::jsonpatch;
20
21void validate_three_ways()
22{
23 std::string schema_str = R"(
24{
25 "$id": "https://example.com/arrays.schema.json",
26 "$schema": "https://json-schema.org/draft/2020-12/schema",
27 "description": "Arrays of strings and objects",
28 "type": "object",
29 "properties": {
30 "fruits": {
31 "type": "array",
32 "items": {
33 "type": "string"
34 }
35 },
36 "vegetables": {
37 "type": "array",
38 "items": { "$ref": "#/$defs/veggie" }
39 }
40 },
41 "$defs": {
42 "veggie": {
43 "type": "object",
44 "required": [ "veggieName", "veggieLike" ],
45 "properties": {
46 "veggieName": {
47 "type": "string",
48 "description": "The name of the vegetable."
49 },
50 "veggieLike": {
51 "type": "boolean",
52 "description": "Do I like this vegetable?"
53 }
54 }
55 }
56 }
57}
58 )";
59
60 std::string data_str = R"(
61{
62 "fruits": [ "apple", "orange", "pear" ],
63 "vegetables": [
64 {
65 "veggieName": "potato",
66 "veggieLike": true
67 },
68 {
69 "veggieName": "broccoli",
70 "veggieLike": "false"
71 },
72 {
73 "veggieName": "carrot",
74 "veggieLike": false
75 },
76 {
77 "veggieName": "Swiss Chard"
78 }

Callers 1

mainFunction · 0.85

Calls 8

parseFunction · 0.85
make_json_schemaFunction · 0.85
pretty_printFunction · 0.85
get_resultMethod · 0.80
validateMethod · 0.45
whatMethod · 0.45
stringMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected