You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the subject of BigInt, JSON specification, section 6 (Numbers) is quite clear about supported number ranges. Going beyond them creates issues of correctly interpreting numbers.
In addition, exposing integers via API in JSON format that may be really big is not a good idea. One can accidentally generate a number that is outside of the range, and different platforms consuming the JSON will interpret the number differently. Even JSON:API has a convention of sending numbers as strings to avoid that problem.
Some time ago JavaScript landed a new type BigInt that can support ranges outside of 253 - 1. Unfortunately this type is not JSON serializable and the only recommended way of transferring it via JSON is: transfer it as a string. That way, every platform can deal with it as it likes.
As such, we're unable to accept this PR. Thanks again for your time and contribution.
The change I made will soon be a part of JSON.parse(.... See this.
I like the solution of treating big integers as strings, however, the big integers are currently being silently modified to wrong values. That is not a great user experience in my opinion.
Unfortunately this type is not JSON serializable and the only recommended way of transferring it via JSON is: transfer it as a string.
I think this is the right decision for the particular project using JSON.
(In paticular, we should make that choice if we have an unspecified number of JavaScript client.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BigInts in request and response are silently modified. This PR adds support for bigints
Description
Uses this library to support bigInts.
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests