Object parse using json-bigint doesn't have Object function
See original GitHub issue`var JSONbigString = require(‘json-bigint’);
var key = ‘{ “key”: 1234567890123456789 }’; var withString = JSONbigString.parse(key);
console.log(Function.prototype.toString.call(withString.constructor));`
Result `console.log(Function.prototype.toString.call(withString.constructor)); ^
TypeError: Function.prototype.toString requires that ‘this’ be a Function at toString (<anonymous>) at Object.<anonymous> (Ravi/office/mix/check.js:6:41) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Expected
function Object() { [native code] }
When you use normal JSON.parse you will get the constructor as expected.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
use the last version instead
After update to 1.0.0, lots of weird problem occurred. I’ve never mind some library do some
prototype pollution
. But there is no options to keep the compatibility to the older version.I filed a PR to add an option to preserve prototype properties on the parsed objects: https://github.com/sidorares/json-bigint/pull/47
Upd.: oh, I thought built-in
BigInt
support was not available inv0.4.0
, but apparently it is, so, yeah, better to just stick tov0.4.0