Closed colinfindlay-nz closed 4 years ago
Not sure there is something I can do about it. This rely on toJSON
function which is fine in most case, maybe a solution would be to rely on toString
instead but that would break people relying on toJSON
. A last solution would be to failover from toJSON
to toString
in case of an error.
Thank you for reporting this issue. I just realized that BigInt was not a build-in JS object but a type. It makes complete sense to support it and there is not incompatibility with how with deal with objects. Release 5.5.0 is out with BigInt support.
Thank you so much! You're awesome!
Describe the bug
Serializing data on Node 12 with any BigInt datatypes produces
TypeError: Do not know how to serialize a BigInt at JSON.stringify ()
at Stringifier.stringify (/var/task/node_modules/csv-stringify/lib/index.js:335:136)
at Stringifier._transform (/var/task/node_modules/csv-stringify/lib/index.js:230:20)
at Stringifier.Transform._read (_stream_transform.js:191:10)
at Stringifier.Transform._write (_stream_transform.js:179:12)
at doWrite (_stream_writable.js:441:12)
at writeOrBuffer (_stream_writable.js:425:5)
at Stringifier.Writable.write (_stream_writable.js:316:11)
at module.exports (/var/task/node_modules/csv-stringify/lib/sync.js:18:17)
To Reproduce
Something like:
csvstringify([{"myBigNumber": new BigInt(123)}]);