Skip to content

json: parse quoted integers exactly#255

Open
fallintoplace wants to merge 1 commit into
anthropics:mainfrom
fallintoplace:fix/exact-json-integer-string-parsing
Open

json: parse quoted integers exactly#255
fallintoplace wants to merge 1 commit into
anthropics:mainfrom
fallintoplace:fix/exact-json-integer-string-parsing

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

Parse quoted integer strings exactly in the JSON helpers instead of routing decimal/exponent forms through f64.

Why

parse_int_from_str was exact for plain integer strings, but strings like "1e5" or "9007199254740993.0" fell back to f64. That meant values above the 2^53 precision boundary could be silently rounded during JSON decode.

What changed

  • replace the f64 fallback with an exact decimal/scientific parser for quoted integer strings
  • keep accepting the integer-like string forms the helpers already supported, including zero-fraction decimals and scientific notation
  • handle exact negative exponents like "1200e-2"
  • add regression coverage for 2^53 boundary cases, u64::MAX with .0, and non-integral exponent strings

Validation

  • cargo test -p buffa

@github-actions

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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.

1 participant