Skip to content

Fix JSON number parsing - #21

Merged
nmatt0 merged 1 commit into
nmatt0:masterfrom
0xDyews:json-number-parsing-fix
Sep 15, 2026
Merged

nmatt0 merged 1 commit into
nmatt0:masterfrom
0xDyews:json-number-parsing-fix

Conversation

@0xDyews

@0xDyews 0xDyews commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fix JSON number parsing

The JSON number parser was accepting some invalid JSON number formats because it did not enforce the required structure of a JSON number before converting it with std::stod().

For example, values such as +1, 01, 1., and 1e could be accepted even though they are not valid JSON numbers.

This updates parse_number() to validate:

  • the optional leading -
  • the integer part and leading zero rules
  • the fractional part
  • the exponent and its optional sign

Valid JSON numbers continue to be accepted.

@nmatt0
nmatt0 merged commit 093d1b7 into nmatt0:master Sep 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants