Skip to content

Main content

JSON Number Plus Sign Rejection

Check an explicit JSON-number lexical token without parsing it as binary64; a leading plus is forbidden but an exponent plus is allowed.

Loading tool…

Description

Check JSON number-token syntax separately from a leading-plus flag.

JSON distinguishes a member's absence, explicit null and other scalar or container values. Source number syntax differs from finite machine-number range, and reserializing a parsed value can change its spelling. Record delimiters also belong to a stream convention rather than automatically forming one valid JSON document.

Check JSON number-token syntax separately from a leading-plus flag.

When to use this tool

Use JSON Number Plus Sign Rejection when you already have numberText and need to check JSON number-token syntax separately from a leading-plus flag.

How to use the tool and how it works

  1. Enter numberText. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read validJsonNumber, leadingPlus. Inspect validJsonNumber, leadingPlus before interpreting the associated values.

Match optional -, a zero or nonzero-leading integer, optional decimal fraction and optional signed exponent, anchored to the entire input; leadingPlus tests the first character separately.1

JSON number syntax forbids a leading plus and leading integer zeros. Lexical validity is separate from the numeric range and precision supported by a parser.2

Input fieldMeaning and unitsAccepted input
numberTextNumber TextRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
validJsonNumberLexical JSON number grammar only; very large exponent forms may be true without a finite numeric value.Required. Boolean.
leadingPlusIndependent flag for an initial +; that spelling is not a valid JSON number.Required. Boolean.
json
{
  "input": {
    "numberText": "+12"
  },
  "output": {
    "validJsonNumber": false,
    "leadingPlus": true
  }
}

Limitations and assumptions

  • This is a lexical grammar check: no whitespace, leading integer zeros or leading + are accepted, but a huge exponent can be syntactically valid without being a finite portable numeric value.
  • 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

Parse and validate the complete intended JSON schema or record stream when structural conformance matters. Preserve original source text when lexical spelling is significant, and decide explicitly whether absent and null members should share a default.

References

  1. Calculation and input contract: json/json-number-plus-sign-rejection — tool.io

  2. RFC 8259: Numbers — IETF

Similar or alternative tools