| 487 | } |
| 488 | |
| 489 | void optional_format_example() |
| 490 | { |
| 491 | json schema = json::parse(R"( |
| 492 | { |
| 493 | "$id": "/schema_str", |
| 494 | "$schema": "https://json-schema.org/draft/2020-12/schema", |
| 495 | "properties": { |
| 496 | "Date": { |
| 497 | "format": "date-time", |
| 498 | "type": "string" |
| 499 | } |
| 500 | }, |
| 501 | "required": [ |
| 502 | "Date" |
| 503 | ], |
| 504 | "type": "object", |
| 505 | "unevaluatedProperties": false |
| 506 | } |
| 507 | )"); |
| 508 | |
| 509 | auto compiled = jsoncons::jsonschema::make_json_schema(schema, |
| 510 | jsonschema::evaluation_options{}.require_format_validation(true)); |
| 511 | |
| 512 | json data = json::parse(R"( |
| 513 | { "Date" : "2024-03-19T26:34:56Z" } |
| 514 | )"); |
| 515 | |
| 516 | jsoncons::json_decoder<ojson> decoder; |
| 517 | compiled.validate(data, decoder); |
| 518 | ojson output = decoder.get_result(); |
| 519 | std::cout << pretty_print(output) << "\n"; |
| 520 | } |
| 521 | |
| 522 | void walk_example() // since 0.175.0 |
| 523 | { |
no test coverage detected