concept Data & storage
JSON document fields and schema validation
A missing field can fail a presence check. A field set to null is present but, like any value of the wrong type, can fail a type check. An undeclared field fails only if the schema’s policy rejects it.
What it means
Valid JSON syntax does not establish that a document meets a schema or that its contents are true. In {"age":null}, the age field is present. Whether null is an allowed value is a separate question.
The simulation uses four keywords from JSON Schema 2020-12: type, required, properties, and additionalProperties. Its default schema expects an object with a required integer age and an optional string name.
For an object, required checks whether a named field exists. A type rule checks the value, and null is a type of its own. JSON Schema validation: type and required. The properties keyword applies rules to declared fields when they are present. In this schema, additionalProperties governs all other field names. JSON Schema core: properties and additionalProperties.
Try it
Use made-up values in Synthetic JSON document. The starting document, {"age":3}, passes with no field-level issues: age is present, its value is an integer, and there are no extra fields. The starting settings are Allow age to be NULL = No and Unexpected-property policy = deny.
JSON document fields and schema validation
Inspect synthetic documents against a declared small schema; show exact field-level outcomes and distinguish syntactic validity from schema and business rules.
Synthetic inputs only. This is not a measurement of your hardware or service.
Syntax is inspected before schema rules. Numeric tokens retain their original decimal/exponent representation; integer means zero mathematical fractional part, not an integer-looking string.
Syntax first, then the declared schema subset
- Passes the modeled schema
- Yes
- Numeric inspection is unproved
- No
Field-specific schema issues
No field-level issue was established by this result.
Evaluated evidence
- Synthetic JSON document
- {"age":3}
- Allow age to be NULL
- no
- Unexpected-property policy
- deny
- JSON Schema dialect
- 2020-12
- Implemented validation subset
- type,required,properties,additionalProperties
A bounded single-line input and small fixed schema, not a complete JSON Schema engine or database validator. Multiline input, duplicate keys, depth over 8 and more than 256 parsed values are rejected by this model, not declared universally invalid JSON. No business rule such as positive age is inferred.
About this model
Every input is local synthetic evidence. Numbers stay as raw text until this model validates them. The shown evaluated values come from the same result as the explanation.
Presets replace the entire scenario. Reset restores all starting fields, scenario selection and model state; it does not change the open or closed state of this help or article FAQ.
No external request, device command, stored-input history or measurement is performed.
Compare these edits against the starting settings:
- Remove the value but leave the colon:
{"age":}is malformed. The model reportsinvalidand stops before schema evaluation. - Remove the entire member instead:
{}parses as an object, but the issue at/ageisrequired. There is no value to type-check. - Supply an explicit value:
{"age":null}passes the presence check, but the issue at/ageis nowtype. Switching Allow age to be NULL to Yes lets this document pass; it does not makeageoptional. With{"age":"3"}, the issue is stilltype: the quoted value is a string, not an integer. - Add a field:
{"age":3,"extra":1}still has a validage. The issue is at/extra, whereadditionalPropertiesisfalseunderdeny. Changing Unexpected-property policy toallowadmits that field without changing the rule forage.
For an integer check, what matters is whether the number has a zero mathematical fractional part, not whether it was written with a decimal point or exponent. JSON Schema validation: type. Both 3.0 and 30e-1 represent exactly three and pass as age. The Keep the original fractional token preset uses 2.000000000000000001 instead. The model checks the original number text, so it finds the nonzero fraction rather than rounding it away.
The Exceed the bounded numeric inspection range preset uses {"age":1e65}. Its exponent exceeds the model’s inspection limit, so the result is unknown, not a type failure. Reset restores the starting document, both settings, and the default scenario, and clears errors, history, and any comparison.
In practice
First distinguish a syntax error from a limit of the checker. This simulation takes one line of at most 8,192 characters and rejects duplicate field names, nesting deeper than 8, and more than 256 parsed values. Those restrictions are not general JSON syntax rules. The simulation is neither a complete JSON Schema engine nor a database validator.
Once a document parses, read the field path and the failed rule together. A required issue at /age calls for supplying the field; a type issue at the same path calls for checking the value against the allowed types. An additionalProperties issue calls for comparing the field name with the schema, not changing its value.
Even {"age":-1} passes this subset: the schema requires an integer, not a positive integer. If your application needs a positive age, check that rule separately. If it needs someone’s actual age, a schema pass is not proof. Syntax establishes that the text can be read; schema validation establishes only that the declared rules are met.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Is null the same as a missing field?
No. A present member whose value is null is different from an absent member. Required checks presence, while type rules decide whether the present null is accepted.
Does valid JSON satisfy a schema?
Not necessarily. The lab accepts a bounded single-line JSON input, checks syntax, then applies its declared schema subset. A syntactically valid string value does not satisfy the required integer age type. Rejecting a multiline input here is a model input restriction, not a JSON syntax rule.
Can unknown fields be allowed?
Yes when the declared additionalProperties policy permits them. Setting it to false restricts unmatched names; a field being unfamiliar to this example is not itself a JSON syntax error.
Does schema validity prove a business rule?
No. This schema does not require a positive age or verify a real person. It also preserves numeric tokens exactly, so an almost-integer decimal cannot pass by being rounded to a JavaScript integer.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- JSON Schema validation
type; required. integer means a number with zero mathematical fractional part; null is its own type; required distinguishes absence.
Checked .
- JSON Schema core
10.3.2.1 properties;10.3.2.3 additionalProperties. Properties applies to matched names; additionalProperties applies to names not covered by the declared properties/patternProperties annotations.
Checked .