https://github.com/nicolasparada/js-json-bigint
BigInt support for JSON encoding
https://github.com/nicolasparada/js-json-bigint
bigint int64 json npm-package
Last synced: 3 months ago
JSON representation
BigInt support for JSON encoding
- Host: GitHub
- URL: https://github.com/nicolasparada/js-json-bigint
- Owner: nicolasparada
- License: isc
- Created: 2019-03-06T03:43:51.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-03-23T00:49:39.000Z (about 2 years ago)
- Last Synced: 2024-04-14T07:10:36.232Z (about 1 year ago)
- Topics: bigint, int64, json, npm-package
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON BigInt
JavaScript library that allows encoding JSON with BigInt support.
JavaScript JSON API doesn't work with numbers too big. If you are working with 64-bit integers in your server, this library got you covered. 64-bits integers will be parsed as bigint 😉
No dependencies. 443 bytes.
## Example
```js
import JSONBigInt from 'https://unpkg.com/@nicolasparada/[email protected]/json-bigint.js'const input = '{"big":9223372036854775807,"small":123}'
console.log('input:', input)const r1 = JSON.parse(input)
console.group('built-in JSON')
console.log('parsed:', r1)
console.log('stringified:', JSON.stringify(r1))
console.groupEnd()const r2 = JSONBigInt.parse(input)
console.group('JSONBigInt')
console.log('parsed:', r2)
console.log('stringified:', JSONBigInt.stringify(r2))
console.groupEnd()
``````
input: {"big":9223372036854775807,"small":123}built-in JSON
parsed: { big: 9223372036854776000, small: 123 }
stringified: {"big":9223372036854776000,"small":123}JSONBigInt
parsed: { big: 9223372036854775807n, small: 123 }
stringified: {"big":9223372036854775807,"small":123}
```