JSON Revier

Benchmark created on


Preparation HTML

<script src="
https://cdn.jsdelivr.net/npm/lossless-json@4.0.2/lib/umd/lossless-json.min.js
"></script>

Setup

function bigintReviver(key, value, context) {
  if (typeof value === 'number' && value > Number.MAX_SAFE_INTEGER) {
    return context.source; 
  }
  return value;
}
function customNumberParser(value) {
  return LosslessJSON.isSafeNumber(value) ? parseInt(value) : value
}


const jsonString = '{"bigNumber": 123456789012345678901234567890, "regularNumber": 123, "string": "abc", "boolean": false}';


Test runner

Ready to run.

Testing in
TestOps/sec
Native
JSON.parse(jsonString)
ready
Custom
JSON.parse(jsonString, bigintReviver)
ready
lossless-json
LosslessJSON.parse(jsonString, null, customNumberParser)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.