body-parser icon indicating copy to clipboard operation
body-parser copied to clipboard

Any plans to support larger than 53-bit integers?

Open johnnysprinkles opened this issue 6 years ago • 3 comments

Integers larger than 53 bits are valid JSON, but when parsed by JSON.parse they get truncated down to 53 bits and lose a few least significant digits. We have 64 bit integers coming from our backend and use https://www.npmjs.com/package/json-bigint to parse, any chance of adding an option for replace the built-in JSON.parse with a custom function, or just a boolean option for using json-bigint?

johnnysprinkles avatar Nov 05 '17 07:11 johnnysprinkles

Should just need to provide an option defaulted to JSON.parse. Then you can bring your own JSONBigInt parser.

parser = opts.parser || JSON.parse;

kjvalencik avatar Nov 16 '17 22:11 kjvalencik

Adding a parser option does make the reviver option redundant since it could be accomplished with:

{
    parser : body => JSON.parse(body, reviver)
}

kjvalencik avatar Nov 20 '17 16:11 kjvalencik

Right on, thanks!

johnnysprinkles avatar Nov 22 '17 18:11 johnnysprinkles