Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
json-bigint-patch
Advanced tools
Readme
JSON.parse/stringify with bigints support. Based on Douglas Crockford JSON.js package and BigInt feature of JavaScript.
While most JSON parsers assume numeric values have same precision restrictions as IEEE 754 double, JSON specification does not say anything about number precision. Any floating point number in decimal (optionally scientific) notation is valid JSON value. It's a good idea to serialize values which might fall out of IEEE 754 integer precision as strings in your JSON api, but { "value" : 9223372036854775807}
, for example, is still a valid RFC4627 JSON string, and in most JS runtimes the result of JSON.parse
is this object: { value: 9223372036854776000 }
==========
example:
var json = '{ "value" : 9223372036854775807, "v2": 123 }';
console.log('Input:', json);
console.log('');
console.log('JavaScript built-in JSON:')
var r = JSON.parse(json);
console.log('Native JSON.parse(input).value : ', r.value.toString());
console.log('Native JSON.stringify(JSON.parse(input)):', JSON.stringify(r));
require('json-bigint-patch');
console.log('\n\nPatched JSON:');
var r1 = JSON.parse(json);
console.log('Patched JSON.parse(input).value : ', r1.value.toString());
console.log('Patched JSON.stringify(JSON.parse(input)):', JSON.stringify(r1));
Output:
Input: { "value" : 9223372036854775807, "v2": 123 }
JavaScript built-in JSON:
Native JSON.parse(input).value : 9223372036854776000
Native JSON.stringify(JSON.parse(input)): {"value":9223372036854776000,"v2":123}
Patched JSON:
Patched JSON.parse(input).value : 9223372036854775807
Patched JSON.stringify(JSON.parse(input)): {"value":9223372036854775807,"v2":123}
FAQs
JSON.parse with bigints support
We found that json-bigint-patch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).