...
JSON Schemas can also be written to conditionally apply annotations. For example, consider the following JSON Schema:
Code Block | ||
---|---|---|
| ||
{ "type": "object", "properties": { "country": { "type": "string", "enum": ["United States", "Canada"] }, "if": { "properties": { "country": { "const": "United States" } }, "required": ["country"] }, "then": { "properties": { "measurementSystem": { "const": "Imperial" } } }, "else": { "properties": { "measurementSystem": { "const": "Metric" } } } } } |
...