-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Description
I got big number serializing problem in JSON, so I decide to override JSON.parse
and JSON.stringify
with this package globally, then I encountered some errors in other js codes,
it seems Object
parsed by JSONbig
lost hasOwnProperty
function:
import * as JSONbig from "json-bigint";
var json = '{ "value" : 9223372036854775807, "v2": 123 }';
console.log(
JSON.parse(json).hasOwnProperty("value")
);
console.log(
JSONbig.parse(json).hasOwnProperty("value")
);
module def for typescript:
declare module "json-bigint" {
function parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
function stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
function stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
}
got output:
true
console.log(JSONbig.parse(json).hasOwnProperty("value"));
^
TypeError: JSONbig.parse(...).hasOwnProperty is not a function
at Object.<anonymous> (\resources\json-bigint\dist\index.js:27:33)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
error Command failed with exit code 1.
klesunklesun
Metadata
Metadata
Assignees
Labels
No labels