How to use the lossless-json.LosslessNumber function in lossless-json

To help you get started, we’ve selected a few lossless-json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskrabbit / elasticsearch-dump / lib / jsonparser.js View on Github external
const _replacer = (key, value) => {
  if (_.isString(value) && DECIMAL_REGEX.test(value) &&
    !isNaN(value) && parseFloat(value) > Number.MAX_SAFE_INTEGER) {
    return new LosslessJSON.LosslessNumber(value.replace(/^\+/, ''))
  } else if (value instanceof Decimal) {
    return new LosslessJSON.LosslessNumber(value.toString())
  } else {
    return value
  }
}
github taskrabbit / elasticsearch-dump / lib / jsonparser.js View on Github external
const _replacer = (key, value) => {
  if (_.isString(value) && DECIMAL_REGEX.test(value) &&
    !isNaN(value) && parseFloat(value) > Number.MAX_SAFE_INTEGER) {
    return new LosslessJSON.LosslessNumber(value.replace(/^\+/, ''))
  } else if (value instanceof Decimal) {
    return new LosslessJSON.LosslessNumber(value.toString())
  } else {
    return value
  }
}

lossless-json

Parse JSON without risk of losing numeric information

MIT
Latest version published 3 months ago

Package Health Score

67 / 100
Full package analysis