Description
Validate JSON number grammar.
A JSON number's grammar, decimal spelling, and parsed binary value are different layers. Exponents, leading zeros, and negative zero can carry lexical information lost during numeric conversion.
Validate JSON number grammar.
When to use this tool
Use JSON: JSON Number Negative Zero Lexeme when you need a numeric token's spelling or serialization convention.
How to use the tool and how it works
- Enter lexeme. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read result. Expand result to inspect the returned fields.
Validate JSON number grammar. Inspect the coefficient before any exponent for nonzero digits, returning negativeSign and negativeZero when a minus sign prefixes an all-zero coefficient.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| lexeme | Supplied token spelling; it is not automatically decoded text. | Required. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Result | Required. Object. |
| result.negativeZero | Negative Zero | Calculated result member: boolean. |
| result.negativeSign | Negative Sign | Calculated result member: boolean. |
{
"input": {
"lexeme": "-0.00e+12"
},
"output": {
"result": {
"negativeZero": true,
"negativeSign": true
}
}
} Limitations and assumptions
- A tiny nonzero coefficient that underflows numerically is not classified as lexical negative zero; no Number conversion is used.
- Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Use an exact decimal parser when preserving large integers, decimal scale, or lexical round trips is required.
References
Similar or alternative tools
- JSON Number Exponent Negative Zero Label
Validate the number token and inspect exponent presence, its minus sign, and whether every exponent digit is zero.
- JSON Number Leading Zero Grammar Flag
Test strict JSON number grammar and independently flag an optional minus followed by zero and another digit.