-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object parse using json-bigint doesn't have Object function #39
Comments
use the last version instead
After update to 1.0.0, lots of weird problem occurred. I've never mind some library do some |
Thanks! |
I filed a PR to add an option to preserve prototype properties on the parsed objects: #47 var JSONbig = require('json-bigint');
var JSONBigInt = JSONbig({ objectBaseClass: Object }); // default is null
var key = '{ "key": 1234567890123456789 }';
// should not result in TypeError thanks to `objectBaseClass: Object`
console.log(Function.prototype.toString.call(withString.constructor));` Upd.: oh, I thought built-in |
Please merge #47 as the object prototype also provide |
I'm curious, why do we want to have no prototype on parsed object ? On a side note, since this package seems not being maintained, I forked it and rewrite in TS while fixing couple of issues, including this one. My approach is to call setPrototype on the parsed object later on, is there something wrong with that ? Am I missing something ? Btw my forked is here https://github.com/haoadoresorange/when-json-met-bigint, feel free to give it a try and let me know if something's wrong xD |
`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 ()
at Object. (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.
The text was updated successfully, but these errors were encountered: