Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 1, 2024 via pnpm

json-bigint 1.0.0

JSON.parse with bigints support
Package summary
Share
0
issues
1
license
2
MIT
Package created
12 Sep 2013
Version published
14 Jul 2020
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
bignumber.js@9.1.2
json-bigint@1.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of json-bigint 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
bignumber.js9.1.277.37 kBMIT
prod

Visualizations

Frequently Asked Questions

What does json-bigint do?

json-bigint is a powerful JavaScript library that provides a JSON.parse/stringify alternative with bigints support. While standard JSON parsers assume numeric values have the same precision restrictions as IEEE 754 double, json-bigint defies this assumption, recognizing that the JSON specification does not place any restrictions on number precision. It is particularly useful when dealing with large numeric values that would exceed the precision of an IEEE 754 integer, such as { "value" : 9223372036854775807}. With json-bigint, these large values can be parsed accurately, effectively avoiding precision loss which is common in most JavaScript runtimes.

How do you use json-bigint?

To use the json-bigint package, you first need to import the library using the require function. The sample code to parse and stringify JSON using json-bigint looks as follows:

var JSONbig = require('json-bigint');

var json = '{ "value" : 9223372036854775807, "v2": 123 }';
console.log('Input:', json);
console.log('');

console.log('node.js built-in JSON:');
var r = JSON.parse(json);
console.log('JSON.parse(input).value : ', r.value.toString());
console.log('JSON.stringify(JSON.parse(input)):', JSON.stringify(r));

console.log('\n\nbig number JSON:');
var r1 = JSONbig.parse(json);
console.log('JSONbig.parse(input).value : ', r1.value.toString());
console.log('JSONbig.stringify(JSONbig.parse(input)):', JSONbig.stringify(r1));

The library also offers several options to customize its behavior. These include settings for strict parsing, storing BigInts as a string, using native BigInt in place of bignumber.js library, always parsing numbers as BigInt, and more. The usage of options is illustrated clearly in the example sections providing code snippets with different options set.

Where are the json-bigint docs?

For comprehensive information on json-bigint, refer to the README available on its GitHub repository: json-bigint on GitHub. It contains descriptions of the package's functionality and usage, along with numerous examples. The README also includes links to related resources such as the RFC4627 JSON specification and discussions on the handling of large numbers in JavaScript.

The package doesn't appear to have separate documentation apart from the README, but considering the precise explanations and examples provided, the README should serve effectively as its documentation.