Skip to content

Use int64 for object or array length #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Use int64 for object or array length #27

merged 1 commit into from
Apr 12, 2024

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Apr 12, 2024

WARNING: This commit includes breaking changes.

When processing JSON as a stream, it is conceivable that the total number of elements in a JSON object or array exceeds a 32-bit integer.

Switch from int to int64 for a similar reason as why io.Copy returns int64 instead of int.

Note that the depth still uses an int because the stack must be representable in memory, which is limited to the native integer width of the platform. This is similar to how io.Reader.Read returns an int because the length of a []byte cannot possibly be larger than the largest int.

WARNING: This commit includes breaking changes.

When processing JSON as a stream, it is conceivable that
the total number of elements in a JSON object or array
exceeds a 32-bit integer.

Switch from int to int64 for a similar reason as why io.Copy
returns int64 instead of int.

Note that the depth still uses an int because the stack must
be representable in memory, which is limited to the native
integer width of the platform. This is similar to how
io.Reader.Read returns an int because the length of a []byte
cannot possibly be larger than the largest int.
@dsnet dsnet requested review from mvdan and johanbrandhorst April 12, 2024 04:08
@dsnet dsnet merged commit 2f02d56 into master Apr 12, 2024
@dsnet dsnet deleted the length64 branch April 12, 2024 20:29
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.

3 participants