JSON.stringify() doesn't know how to serialize a BigInt
See original GitHub issueNot certain how to handle this situation:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
39 | toObject() {
> 40 | return JSON.parse(JSON.stringify(this));
| ^
41 | }
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:9
Top Results From Across the Web
bigint - # - json
Serialization and Deserialization ... It should be noted that how you choose to serialize your BigInts affects how you deserialize your BigInts.
Read more >JSON stringify and PostgreSQL bigint compliance
The nature of the library permits not to worry about type ambiguity and de-serialization, as everything that's serialized goes into the server, ...
Read more >"TypeError: Do not know how to serialize a BigInt" - General
2nd thing to know, is a BigInt cannot be directly serialised to JSON ... to serialise (likely JSON.stringify) the data before being written...
Read more >24 Typeerror: Do Not Know How To Serialize A Bigint 12 ...
Below is the best information and knowledge about typeerror: do not know how to serialize a bigint compiled and compiled by the BMR...
Read more >JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
@jakobkummerow Ok, makes sense. For anyone else stumbling upon this, the verified TL;DR fix for the above problem is:
Wouldn’t it be easier to just monkey patch (hijack)
BigInt
? That’s the MDN recommendation.If you do it this way, you don’t have to add an anonymous function into every call of
JSON.stringify
. It applies globally to all such calls.