bigint-json
Simple package that allows you to use JSON.parse
& JSON.stringify
with BigInt
support.
It works by converting bigints to string and appending n
when stringifying and finding strings representing numbers ending with n
and converting then to BigInt
when parsing
Install
$ npm install bigint-json
Usage
const bigintJSON = ; const someObject = someKey: 1234n; const json = bigintJSON; // '{"someKey":"1234n"}' const parsed = bigintJSON; // { someKey: 1234n }
Works with nested objects as well
It uses Douglas Crockford JSON.js package