{"_id":"@bybrave/json-bigint2","name":"@bybrave/json-bigint2","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@bybrave/json-bigint2","version":"2.0.0","description":"Maintained fork of json-bigint — JSON.parse/stringify with big-number support, native BigInt, TypeScript types","main":"index.js","types":"index.d.ts","scripts":{"test":"node --test test/*.test.js"},"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/json-bigint2.git"},"bugs":{"url":"https://github.com/bybraveHQ/json-bigint2/issues"},"homepage":"https://github.com/bybraveHQ/json-bigint2#readme","keywords":["JSON","bigint","bignumber","parse","stringify","json-bigint","typescript"],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"contributors":[{"name":"Andrey Sidorov","email":"andrey.sidorov@gmail.com","url":"author of the original json-bigint"}],"license":"MIT","funding":"https://ko-fi.com/bybrave","engines":{"node":">=18"},"dependencies":{"bignumber.js":"^9.1.2"},"_id":"@bybrave/json-bigint2@2.0.0","gitHead":"a82914119e91c3a1b2b0af7ea529e01ca5ac1d31","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-DC4yDkFAXVlQr1LFRTMBbVf/BulGjqJV4cR/WVU8mgJ1XIxHZa3z2YUHvwMIzTJymUB+MA0X2hx5iYSBt2RcbA==","shasum":"93b3d3c13d29dec78bcc5f0a0b0c81acce1d5de5","tarball":"https://registry.npmjs.org/@bybrave/json-bigint2/-/json-bigint2-2.0.0.tgz","fileCount":7,"unpackedSize":37974,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCB/+uhX2EvtYvcmXPktkPADfov34vy3M/IqiLZIiSzcQIhANl2JfmIVJgyxq1Ii9F9WlqWwHU0ZrxtWa/q2BLq55Hz"}]},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"directories":{},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/json-bigint2_2.0.0_1783199140448_0.38979870639425407"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-04T21:05:40.325Z","2.0.0":"2026-07-04T21:05:40.590Z","modified":"2026-07-04T21:05:40.890Z"},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"description":"Maintained fork of json-bigint — JSON.parse/stringify with big-number support, native BigInt, TypeScript types","homepage":"https://github.com/bybraveHQ/json-bigint2#readme","keywords":["JSON","bigint","bignumber","parse","stringify","json-bigint","typescript"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/json-bigint2.git"},"contributors":[{"name":"Andrey Sidorov","email":"andrey.sidorov@gmail.com","url":"author of the original json-bigint"}],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"bugs":{"url":"https://github.com/bybraveHQ/json-bigint2/issues"},"license":"MIT","readme":"# @bybrave/json-bigint2\n\n[![CI](https://github.com/bybraveHQ/json-bigint2/actions/workflows/ci.yml/badge.svg)](https://github.com/bybraveHQ/json-bigint2/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/@bybrave/json-bigint2.svg)](https://www.npmjs.com/package/@bybrave/json-bigint2)\n[![node](https://img.shields.io/node/v/@bybrave/json-bigint2.svg?color=339933&logo=node.js&logoColor=white)](https://www.npmjs.com/package/@bybrave/json-bigint2)\n[![types](https://img.shields.io/badge/types-included-3178C6?logo=typescript&logoColor=white)](index.d.ts)\n[![license](https://img.shields.io/npm/l/@bybrave/json-bigint2.svg?color=blue)](LICENSE)\n\nMaintained fork of [json-bigint](https://github.com/sidorares/json-bigint) — `JSON.parse` / `JSON.stringify` that preserve numbers beyond `Number.MAX_SAFE_INTEGER` instead of silently corrupting them.\n\n```js\nJSON.parse('{\"id\":9223372036854775807}').id\n// 9223372036854775806  ← corrupted\n\nrequire('@bybrave/json-bigint2')({ useNativeBigInt: true }).parse('{\"id\":9223372036854775807}').id\n// 9223372036854775807n ← exact\n```\n\n## Why this fork\n\nThe original `json-bigint` has not been released since 2020, and the code published on npm is older than its master branch — several fixes were merged upstream but never shipped. `@bybrave/json-bigint2` is a drop-in replacement that ships the fixed code plus:\n\n| Change | Upstream issue |\n|---|---|\n| TypeScript type definitions included | [#34](https://github.com/sidorares/json-bigint/issues/34) |\n| Floats no longer crash `useNativeBigInt` mode (shipped, was unreleased on npm) | [#49](https://github.com/sidorares/json-bigint/issues/49), [#88](https://github.com/sidorares/json-bigint/issues/88) |\n| Numbers beyond the double range (`3e+500`, 400-digit integers) parse instead of throwing `Bad number` | [#25](https://github.com/sidorares/json-bigint/issues/25), [#26](https://github.com/sidorares/json-bigint/issues/26) |\n| `objectProto` option: parsed objects get a normal prototype (`hasOwnProperty`, `toString` work) | [#39](https://github.com/sidorares/json-bigint/issues/39), [#64](https://github.com/sidorares/json-bigint/issues/64) |\n| Strict JSON number grammar: `01`, `-01`, `5.`, `1e` are rejected like `JSON.parse` does | [#19](https://github.com/sidorares/json-bigint/issues/19) |\n| Parse errors are real `SyntaxError` instances (stack trace, `instanceof Error`) | — |\n| Zero dev-dependency test suite on `node:test`, CI on Node 18/20/22 | — |\n\n## Install\n\n```sh\nnpm install @bybrave/json-bigint2\n```\n\n## Usage\n\n```js\nconst JSONbig = require('@bybrave/json-bigint2')({ useNativeBigInt: true });\n\nconst payload = '{\"id\":9223372036854775807,\"name\":\"deep\"}';\nconst data = JSONbig.parse(payload);\ndata.id;                    // 9223372036854775807n\nJSONbig.stringify(data);    // '{\"id\":9223372036854775807,\"name\":\"deep\"}'\n```\n\nWithout options, unsafe integers become [bignumber.js](https://github.com/MikeMcl/bignumber.js) instances (original behaviour):\n\n```js\nconst JSONbig = require('@bybrave/json-bigint2');\nJSONbig.parse('{\"id\":9223372036854775807}').id.toFixed(); // '9223372036854775807'\n```\n\nTypeScript:\n\n```ts\nimport JSONbig = require('@bybrave/json-bigint2');\n\nconst parser = JSONbig({ useNativeBigInt: true, objectProto: true });\nconst data = parser.parse(payload);\n```\n\n## Options\n\n| Option | Default | Description |\n|---|---|---|\n| `useNativeBigInt` | `false` | Use native `BigInt` instead of bignumber.js |\n| `alwaysParseAsBig` | `false` | Parse every integer as big, not only unsafe ones |\n| `storeAsString` | `false` | Store big numbers as plain strings |\n| `strict` | `false` | Throw on duplicate object keys |\n| `objectProto` | `false` | Parsed objects get `Object.prototype` instead of a null prototype |\n| `protoAction` | `'error'` | `\"__proto__\"` key handling: `'error'` \\| `'ignore'` \\| `'preserve'` |\n| `constructorAction` | `'error'` | `\"constructor\"` key handling: `'error'` \\| `'ignore'` \\| `'preserve'` |\n\nNotes:\n\n- `objectProto: true` is safe against prototype pollution: suspicious keys are still guarded by `protoAction`/`constructorAction`, and member assignment never touches the actual prototype.\n- In `useNativeBigInt` mode a number that overflows the double range **and** keeps a fractional part (e.g. `1.55…5e+309`) parses as `Infinity`, mirroring `JSON.parse`.\n\n## Migrating from json-bigint\n\nIt is a drop-in replacement:\n\n```diff\n- const JSONbig = require('json-bigint')({ useNativeBigInt: true });\n+ const JSONbig = require('@bybrave/json-bigint2')({ useNativeBigInt: true });\n```\n\nThe only behavioural differences are the bug fixes listed above (strict number grammar may reject inputs that were never valid JSON, and parse errors are now `SyntaxError` instances).\n\n## Support\n\nIf this package saves you time, you can support maintenance:\n\n[![Ko-fi](https://img.shields.io/badge/Ko--fi-buy%20me%20a%20coffee-FF5E5B?logo=kofi&logoColor=white)](https://ko-fi.com/bybrave)\n[![Bitcoin](https://img.shields.io/badge/Bitcoin-BTC-F7931A?logo=bitcoin&logoColor=white)](#support)\n\nBitcoin (BTC): `bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q`\n\n## Credits & license\n\nMIT. Based on [json-bigint](https://github.com/sidorares/json-bigint) by Andrey Sidorov, which builds on Douglas Crockford's reference JSON parser.\n","readmeFilename":"README.md","_rev":"1-30b54db90195cc73a41b7460b854cbda"}