JS library that allows you to easily serialize and deserialize data with BigInt values
Why would I need json-with-bigint?
3 reasons:
You need to convert some data to/from JSON and it includes BigInt values
Native JSON.stringify() and JSON.parse() methods in JS can't work with BigInt
Other libraries and pieces of code that you'll find either can't solve this problem while supporting consistent round-trip operations (meaning, you will not get the same BigInt values if you serialize and then deserialize them) or requires you to specify which properties in JSON include BigInt values, or to change your JSON or the way you want to work with your data
json-with-bigint advantages
✔️ Supports consistent round-trip operations with JSON
✔️ No need to specify which properties in JSON include BigInt values. Library will find them itself
✔️ No need to change your JSON or the way you want to work with your data
✔️ You don't have to memorize this library's API, you already know it. Just skip the dot, and that's it (JSONParse(), JSONStringify())
✔️ Parsed big number values are just regular BigInt. Parses and stringifies all other values other than big numbers the same way as native JSON methods in JS do. Signatures match too. You can just replace every JSON.parse() and JSON.strinfigy() in your project with JSONParse() and JSONStringify(), and it will work
✔️ Supports modern features (context.source, rawJSON, etc.)
✔️ If the browser doesn't support the reviver functionality in JSON.parse, this library will safely fall back to the implementation that doesn't need it and will continue to work.
✔️ Correctly parses float numbers and negative numbers
✔️ Correctly parses pretty printed JSON (formatted with newline and whitespace characters)