| 520 | } |
| 521 | |
| 522 | void walk_example() // since 0.175.0 |
| 523 | { |
| 524 | std::string schema_str = R"( |
| 525 | { |
| 526 | "$id": "https://example.com/arrays.schema.json", |
| 527 | "$schema": "https://json-schema.org/draft/2020-12/schema", |
| 528 | "description": "Arrays of strings and objects", |
| 529 | "type": "object", |
| 530 | "properties": { |
| 531 | "fruits": { |
| 532 | "type": "array", |
| 533 | "items": { |
| 534 | "type": "string" |
| 535 | } |
| 536 | }, |
| 537 | "vegetables": { |
| 538 | "type": "array", |
| 539 | "items": { |
| 540 | "$ref": "#/$defs/veggie" |
| 541 | } |
| 542 | } |
| 543 | }, |
| 544 | "$defs": { |
| 545 | "veggie": { |
| 546 | "type": "object", |
| 547 | "required": [ |
| 548 | "veggieName", |
| 549 | "veggieLike" |
| 550 | ], |
| 551 | "properties": { |
| 552 | "veggieName": { |
| 553 | "type": "string", |
| 554 | "description": "The name of the vegetable." |
| 555 | }, |
| 556 | "veggieLike": { |
| 557 | "type": "boolean", |
| 558 | "description": "Do I like this vegetable?" |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | )"; |
| 565 | |
| 566 | auto schema = jsoncons::ojson::parse(schema_str); |
| 567 | auto compiled = jsonschema::make_json_schema(std::move(schema)); |
| 568 | |
| 569 | std::string data_str = R"( |
| 570 | { |
| 571 | "fruits": [ |
| 572 | "apple", |
| 573 | "orange", |
| 574 | "pear" |
| 575 | ], |
| 576 | "vegetables": [ |
| 577 | { |
| 578 | "veggieName": "potato", |
| 579 | "veggieLike": true |