Skip to content

128-bit integer encoding and decoding support#1858

Merged
kperryua merged 1 commit intoswiftlang:experimental/new-codablefrom
kperryua:new-codable/128-bit-support
Mar 30, 2026
Merged

128-bit integer encoding and decoding support#1858
kperryua merged 1 commit intoswiftlang:experimental/new-codablefrom
kperryua:new-codable/128-bit-support

Conversation

@kperryua
Copy link
Copy Markdown
Contributor

128-bit integer support for new-codable APIs. In the absence of Decimal, which would create a Foundation dependency, some large integers formatted as "floating point" numbers (e.g. contains ., e, or E in JSON) will not parse correctly that do in `JSONDecoder.

Enables tests migrated from Foundation JSONDecoder tests

Addresses #1831

@kperryua kperryua added the new-codable Related to new Swift (de)serialization APIs label Mar 27, 2026
@kperryua
Copy link
Copy Markdown
Contributor Author

At some point we may consider an alternative parser that can parse integer-containing floats directly as integers without using Double (or Decimal), but that's far from straightforward.

Decoding integer-containing floats as integers has implications for true stream parsing as well. We might end up being required to buffer input characters for numbers to handle more complex cases. This could incur additional overhead for integer parsing.

Alternatively, we could reject any .eE characters when being asked to decode an integer type. This is what some other systems do, like serde.

@kperryua kperryua linked an issue Mar 27, 2026 that may be closed by this pull request
@kperryua kperryua merged commit df28bc3 into swiftlang:experimental/new-codable Mar 30, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-codable Related to new Swift (de)serialization APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

128-bit integer support throughout new-codable

1 participant