JSON is a common format, but “valid JSON” and “valid extraction” answer different questions.
A small extraction contract
revenue, a finite nonnegative number, and currency, either "USD" or "EUR". Both are required; extra fields are rejected. The nonnegative rule is a task assumption, not a universal accounting law.This is a valid JSON response:
{"revenue": 120, "currency": "USD"}"120" is different from the number 120. One JSON Schema expression of the structural contract is:{
"type": "object",
"properties": {
"revenue": {"type": "number", "minimum": 0},
"currency": {"type": "string", "enum": ["USD", "EUR"]}
},
"required": ["revenue", "currency"],
"additionalProperties": false
}required and additionalProperties keywords matter: declaring properties alone neither requires their presence nor forbids other fields. minimum supplies the inclusive lower bound; enum limits the currency choices.NaN and Infinity. That does not mean every parser or runtime handles all valid numeric magnitudes and decimal precision identically: RFC 8259, §6 explicitly allows implementation limits. A production contract must also choose a numeric representation and reject nonfinite runtime values or overflow before use. The schema above is an illustration, not a promise of arbitrary-precision arithmetic.Four checks, four different conclusions
| Check | Question | Result for the example |
|---|---|---|
| JSON syntax | Can the text be parsed as strict JSON? | Yes |
| Schema and constraints | Are the required fields, types and allowed values satisfied? | Yes: 120 is nonnegative and USD is allowed |
| Factual evidence | Does the identified filing report this amount, currency, scale and period? | Unresolved without checking that filing |
| Authority | May this system store, transmit or act on the result? | Determined by access and execution policy |
-1 preserves JSON syntax and numeric type but violates this contract's lower bound. Changing it to "120" preserves syntax but violates its numeric type. Neither failure is proof about what the filing actually says.Even the accepted record could use the wrong company, last year's revenue, or a figure expressed in thousands rather than millions. An extraction process needs the source document, reporting period and location of the supporting passage available for comparison. Requiring a citation field would require citation text; it would not establish that the cited passage supports the number. This is where financial model hallucination remains possible despite perfect formatting.
How the structure is obtained
There are distinct mechanisms behind similar-looking responses:
- Prompting asks the model to follow a format. The request alone does not enforce it.
- Constrained generation restricts what may be generated while decoding. For example, XGrammar, §2.1 describes masking tokens that violate the permitted structure at the current step. The resulting guarantee is relative to the grammar and constraints actually implemented.
- Parsing and validation inspect the returned response. Parsing checks JSON syntax; schema validation checks the declared contract. Application checks can cover additional requirements, including source agreement. Validation detects a failure; it does not itself repair one.
- Retries request another response after a failure. They consume time and budget and can fail again. Repeatedly receiving the same plausible number does not corroborate it.
minimum as unsupported by its constrained-generation interface. A downstream validator must still enforce this example's nonnegative rule; support should be checked for the chosen engine and version.A refusal, interrupted response or exhausted output limit also needs its own outcome. Do not turn an incomplete record into revenue zero or invent a currency to satisfy required fields. Preserve the failure for review or use a bounded retry policy. The same vendor documentation explicitly describes refusals and output-limit truncation as cases where the expected schema may not be returned.
The useful promise is narrow and valuable: an accepted response fits a known interface. Acceptance as financial evidence, and authorization to act on it, require their own checks.
Sources
- RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format, §§4, 6–7: objects, number grammar, numerical interoperability and strings.
- JSON Schema — Objects: property declarations, required fields and additional properties.
- JSON Schema — Numeric types and Enumerated values: numeric types, inclusive bounds and permitted-value sets.
- Dong et al. (2024), XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Models, §2.1: token masking during constrained decoding.
- Claude documentation — Structured outputs: current schema limitations and invalid-output cases; checked 1 November 2026.