Schema validation
The Schema validation panel checks JSON against a JSON Schema, for example to confirm that an API response or a configuration file has the fields and types it should. Select Schema validation on the activity rail, on the right of the window, to open it.
Provide a schema
Section titled “Provide a schema”Give the panel a schema in one of three ways:
- Paste: paste the schema into the box.
- Load File: choose a
.jsonor.schemafile. - Infer: let JSON Digger write a schema from your data; see Infer a schema.
JSON Digger supports JSON Schema drafts 4, 6, 7, 2019-09, and 2020-12. It reads the draft from the schema’s $schema keyword, and uses 2020-12 when there is none. References with $ref to other files or to web addresses are followed.
To reuse a schema, keep it in a file and use Load File.
Infer a schema
Section titled “Infer a schema”To start from your data instead of writing a schema by hand, select a node in the tree, such as an array of records, and select Infer. The schema replaces the content of the box. It describes:
- The type of each value.
- The members of each object, with
requiredlisting the keys that every sampled object has. - The elements of each array, from its first elements.
Review and adjust the inferred schema before you rely on it: it describes the sample it was built from, not the rules your data should follow.
Validate a document or node
Section titled “Validate a document or node”-
Select what to check in the tree: the root row for the whole document, or any node, such as one record. In an NDJSON file, select one record.
-
Select Validate.
A very large node cannot be validated at once; select a smaller part of it. See Limits.
Read the violations
Section titled “Read the violations”The panel shows Valid, or the number of violations, up to 100. Each violation shows:
- The path of the value that failed, as a JSON Pointer inside the node you validated, such as
/users/3/email./is the node itself. - The message, for example
"email" is a required propertyor123 is not of type "string".
When you validated the whole document, click a violation to show its value in the tree. The panel lists up to 100 violations; fix those and validate again to see more.