json-bigint icon indicating copy to clipboard operation
json-bigint copied to clipboard

Plain numbers are incorrectly parsed as BigInt

Open edtz opened this issue 3 years ago • 2 comments

Supposedly, everything lower or equal to Number.MAX_SAFE_INTEGER should be 'number', but it's not the case. Here's repro:

import JsonBigInt from "json-bigint";

const { parse } = JsonBigInt({
    protoAction: "ignore",
    useNativeBigInt: true,
});

console.log(parse(JSON.stringify({ foo: Number.MAX_SAFE_INTEGER, bar: 100 })));

yields { foo: 9007199254740991n, bar: 100 }, should be { foo: 9007199254740991, bar: 100 }

edtz avatar Sep 13 '21 19:09 edtz

Does this issue be resolved? I'm using version 1.0.0 and still got this issue

fyyhome avatar Jun 08 '22 06:06 fyyhome

This issue is resolved inside the repo after this commit, but for some reason author doesn't seem too interested to publish it on npm.

edtz avatar Jun 09 '22 19:06 edtz