package.json 7.8 KB
{
  "_args": [
    [
      {
        "raw": "json-bigint@^0.2.3",
        "scope": null,
        "escapedName": "json-bigint",
        "name": "json-bigint",
        "rawSpec": "^0.2.3",
        "spec": ">=0.2.3 <0.3.0",
        "type": "range"
      },
      "/Users/fzy/project/koa2_Sequelize_project/node_modules/@alicloud/pop-core"
    ]
  ],
  "_from": "json-bigint@>=0.2.3 <0.3.0",
  "_id": "json-bigint@0.2.3",
  "_inCache": true,
  "_location": "/json-bigint",
  "_nodeVersion": "6.9.1",
  "_npmOperationalInternal": {
    "host": "packages-12-west.internal.npmjs.com",
    "tmp": "tmp/json-bigint-0.2.3.tgz_1484003726024_0.7127540863584727"
  },
  "_npmUser": {
    "name": "sidorares",
    "email": "sidorares@yandex.com"
  },
  "_npmVersion": "3.10.8",
  "_phantomChildren": {},
  "_requested": {
    "raw": "json-bigint@^0.2.3",
    "scope": null,
    "escapedName": "json-bigint",
    "name": "json-bigint",
    "rawSpec": "^0.2.3",
    "spec": ">=0.2.3 <0.3.0",
    "type": "range"
  },
  "_requiredBy": [
    "/@alicloud/pop-core"
  ],
  "_resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.2.3.tgz",
  "_shasum": "118d7f6ff1d38659f19f94cf73e64a75a3f988a8",
  "_shrinkwrap": null,
  "_spec": "json-bigint@^0.2.3",
  "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/@alicloud/pop-core",
  "author": {
    "name": "Andrey Sidorov",
    "email": "sidorares@yandex.ru"
  },
  "bugs": {
    "url": "https://github.com/sidorares/json-bigint/issues"
  },
  "dependencies": {
    "bignumber.js": "^4.0.0"
  },
  "description": "JSON.parse with bigints support",
  "devDependencies": {
    "chai": "~1.9.1",
    "mocha": "~1.20.1"
  },
  "directories": {},
  "dist": {
    "shasum": "118d7f6ff1d38659f19f94cf73e64a75a3f988a8",
    "tarball": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.2.3.tgz"
  },
  "gitHead": "7c3dbc180df56d329578b040bf5bedda6769ab63",
  "homepage": "https://github.com/sidorares/json-bigint#readme",
  "keywords": [
    "JSON",
    "bigint",
    "bignumber",
    "parse",
    "json"
  ],
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "sidorares",
      "email": "sidorares@yandex.com"
    }
  ],
  "name": "json-bigint",
  "optionalDependencies": {},
  "readme": "json-bigint\n===========\n\n[![Build Status](https://secure.travis-ci.org/sidorares/json-bigint.png)](http://travis-ci.org/sidorares/json-bigint)\n[![NPM](https://nodei.co/npm/json-bigint.png?downloads=true&stars=true)](https://nodei.co/npm/json-bigint/)\n\nJSON.parse/stringify with bigints support. Based on Douglas Crockford [JSON.js](https://github.com/douglascrockford/JSON-js) package and [bignumber.js](https://github.com/MikeMcl/bignumber.js) library.\n\nWhile 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 }`\n\n==========\n\nexample:\n\n```js\nvar JSONbig = require('json-bigint');\n\nvar json = '{ \"value\" : 9223372036854775807, \"v2\": 123 }';\nconsole.log('Input:', json);\nconsole.log('');\n\nconsole.log('node.js bult-in JSON:')\nvar r = JSON.parse(json);\nconsole.log('JSON.parse(input).value : ', r.value.toString());\nconsole.log('JSON.stringify(JSON.parse(input)):', JSON.stringify(r));\n\nconsole.log('\\n\\nbig number JSON:');\nvar r1 = JSONbig.parse(json);\nconsole.log('JSON.parse(input).value : ', r1.value.toString());\nconsole.log('JSON.stringify(JSON.parse(input)):', JSONbig.stringify(r1));\n```\n\nOutput:\n\n```\nInput: { \"value\" : 9223372036854775807, \"v2\": 123 }\n\nnode.js bult-in JSON:\nJSON.parse(input).value :  9223372036854776000\nJSON.stringify(JSON.parse(input)): {\"value\":9223372036854776000,\"v2\":123}\n\n\nbig number JSON:\nJSON.parse(input).value :  9223372036854775807\nJSON.stringify(JSON.parse(input)): {\"value\":9223372036854775807,\"v2\":123}\n```\n### Options\nThe behaviour of the parser is somewhat configurable through 'options'\n\n#### options.strict, boolean, default false\nSpecifies the parsing should be \"strict\" towards reporting duplicate-keys in the parsed string.\nThe default follows what is allowed in standard json and resembles the behavior of JSON.parse, but overwrites any previous values with the last one assigned to the duplicate-key.\n\nSetting options.strict = true will fail-fast on such duplicate-key occurances and thus warn you upfront of possible lost information.\n\nexample:\n```js\nvar JSONbig = require('json-bigint');\nvar JSONstrict = require('json-bigint')({\"strict\": true});\n\nvar dupkeys = '{ \"dupkey\": \"value 1\", \"dupkey\": \"value 2\"}';\nconsole.log('\\n\\nDuplicate Key test with both lenient and strict JSON parsing');\nconsole.log('Input:', dupkeys);\nvar works = JSONbig.parse(dupkeys);\nconsole.log('JSON.parse(dupkeys).dupkey: %s', works.dupkey);\nvar fails = \"will stay like this\";\ntry {\n    fails = JSONstrict.parse(dupkeys);\n    console.log('ERROR!! Should never get here');\n} catch (e) {\n    console.log('Succesfully catched expected exception on duplicate keys: %j', e);\n}\n```\n\nOutput\n```\nDuplicate Key test with big number JSON\nInput: { \"dupkey\": \"value 1\", \"dupkey\": \"value 2\"}\nJSON.parse(dupkeys).dupkey: value 2\nSuccesfully catched expected exception on duplicate keys: {\"name\":\"SyntaxError\",\"message\":\"Duplicate key \\\"dupkey\\\"\",\"at\":33,\"text\":\"{ \\\"dupkey\\\": \\\"value 1\\\", \\\"dupkey\\\": \\\"value 2\\\"}\"}\n\n```\n\n#### options.storeAsString, boolean, default false\nSpecifies if BigInts should be stored in the object as a string, rather than the default BigNumber.\n\nNote that this is a dangerous behavior as it breaks the default functionality of being able to convert back-and-forth without data type changes (as this will convert all BigInts to be-and-stay strings).\n\nexample:\n```js\nvar JSONbig = require('json-bigint');\nvar JSONbigString = require('json-bigint')({\"storeAsString\": true});\nvar key = '{ \"key\": 1234567890123456789 }';\nconsole.log('\\n\\nStoring the BigInt as a string, instead of a BigNumber');\nconsole.log('Input:', key);\nvar withInt = JSONbig.parse(key);\nvar withString = JSONbigString.parse(key);\nconsole.log('Default type: %s, With option type: %s', typeof withInt.key, typeof withString.key);\n\n```\n\nOutput\n```\nStoring the BigInt as a string, instead of a BigNumber\nInput: { \"key\": 1234567890123456789 }\nDefault type: object, With option type: string\n\n```\n\n\n### Links:\n- [RFC4627: The application/json Media Type for JavaScript Object Notation (JSON)](http://www.ietf.org/rfc/rfc4627.txt)\n- [Re: \\[Json\\] Limitations on number size?](http://www.ietf.org/mail-archive/web/json/current/msg00297.html)\n- [Is there any proper way to parse JSON with large numbers? (long, bigint, int64)](http://stackoverflow.com/questions/18755125/node-js-is-there-any-proper-way-to-parse-json-with-large-numbers-long-bigint)\n- [What is JavaScript's Max Int? What's the highest Integer value a Number can go to without losing precision?](http://stackoverflow.com/questions/307179/what-is-javascripts-max-int-whats-the-highest-integer-value-a-number-can-go-t)\n- [Large numbers erroneously rounded in Javascript](http://stackoverflow.com/questions/1379934/large-numbers-erroneously-rounded-in-javascript)\n\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+ssh://git@github.com/sidorares/json-bigint.git"
  },
  "scripts": {
    "test": "./node_modules/mocha/bin/mocha -R spec --check-leaks test/*-test.js"
  },
  "version": "0.2.3"
}