JSON スキーマ Draft 2020-12
JSON スキーマ validation vocabulary, dialect, および core keywords 用 Draft 2020-12.
Dialect and Vocabulary
JSON Schema Draft 2020-12 reorganizes the specification into a core document and separate vocabulary documents. A dialect is a set of vocabularies identified by a schema dialect URI in the $schema keyword. The validation vocabulary includes type, format, and constraint keywords, while the applicator vocabulary includes keywords like allOf and if-then-else. This modular design lets applications select only the vocabularies they need.
- $schema
- Dialect URI identifying the schema version
- type
- Instance type constraint
- allOf/anyOf/oneOf
- Logical composition of subschemas
- $ref
- Reference to another schema by URI
https://json-schema.org/draft/2020-12/schema type: string oneOf: [...] $ref: #/$defs/addr Conditional Validation
The if, then, and else keywords enable conditional schema application without custom logic. If the if subschema validates, then the then subschema is applied, otherwise the else subschema is applied. This replaces the older draft-04 dependencies pattern with a more expressive form. The assert and annotation keywords distinguish between validation results and informational annotations collected during validation.
Output Formats
Draft 2020-12 defines standard output formats: flag (boolean), basic (flat list of results), detailed (hierarchical), and verbose (with annotations). The structured outputs let applications distinguish which subschema failed and collect annotations like default values. This enables better error messages and tooling integration compared to the boolean-only output of earlier drafts.