{"_id":"json-bignum","_rev":"11-4c7473bcfd3524c7c5ec83402e25bddb","name":"json-bignum","description":"Node.js JSON replacement which handles 64-bit integers and arbitrary-precision decimals.","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"json-bignum","homepage":"https://github.com/datalanche/json-bignum","description":"Node.js JSON replacement which handles 64-bit integers and arbitrary-precision decimals.","version":"0.0.1","repository":{"type":"git","url":"https://github.com/datalanche/json-bignum.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/json-bignum/raw/master/LICENSE"}],"engines":{"node":">=0.8"},"dependencies":{"bigdecimal":"0.6.1"},"_id":"json-bignum@0.0.1","dist":{"shasum":"af5c51cb56fa413f544fa38f8a7aecce3e00affa","tarball":"https://registry.npmjs.org/json-bignum/-/json-bignum-0.0.1.tgz","integrity":"sha512-xBSlPUKg99SHiHyjIQ3MmzDB599BvcfW87YCCrA1n0Z4/uK8uoshUa4GH7OxUvoaXYcicFwS11DU7ytIzoeWsA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDu59ZCN5+tcvt8GKhwVpnRBqQ+KCdGrBaWu+Xxk3BlcQIhAOQiYYOA/HMZF53UpBzVfqZ6WMWi10zIdpVU1wOw4g6k"}]},"_npmVersion":"1.1.69","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.0.2":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"json-bignum","homepage":"https://github.com/datalanche/json-bignum","description":"Node.js JSON replacement which handles 64-bit integers and arbitrary-precision decimals.","version":"0.0.2","repository":{"type":"git","url":"https://github.com/datalanche/json-bignum.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/json-bignum/raw/master/LICENSE"}],"engines":{"node":">=0.8"},"dependencies":{"bigdecimal":"0.6.1"},"_id":"json-bignum@0.0.2","dist":{"shasum":"6e5a403c35400160dfa474096f6ee9a29d164ae3","tarball":"https://registry.npmjs.org/json-bignum/-/json-bignum-0.0.2.tgz","integrity":"sha512-IvSXSi5V8IFbOz+/4PBFcSguiaLIrpj8vFHvbcYXbFtx2OpX/ceADly3WCuZTb+EVvEoblh1/8TNy8/GOLyx0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCheDnOOEnkmpWi7251BaSiqHttM/4P9ZHwk6fCvXOepAIgWWg7SLa8Ff46FBP46pGy2xSZlYrWfsuzkd4mPijLKeI="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]},"0.0.3":{"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"name":"json-bignum","homepage":"https://github.com/datalanche/json-bignum","description":"Node.js JSON replacement which handles 64-bit integers and arbitrary-precision decimals.","version":"0.0.3","repository":{"type":"git","url":"https://github.com/datalanche/json-bignum.git"},"main":"lib/index.js","directories":{"lib":"./lib"},"licenses":[{"type":"MIT","url":"https://github.com/datalanche/json-bignum/raw/master/LICENSE"}],"engines":{"node":">=0.8"},"bugs":{"url":"https://github.com/datalanche/json-bignum/issues"},"_id":"json-bignum@0.0.3","dist":{"shasum":"41163b50436c773d82424dbc20ed70db7604b8d7","tarball":"https://registry.npmjs.org/json-bignum/-/json-bignum-0.0.3.tgz","integrity":"sha512-2WHyXj3OfHSgNyuzDbSxI1w2jgw5gkWSWhS7Qg4bWXx1nLk3jnbwfUeS0PSba3IzpTUWdHxBieELUzXRjQB2zg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCmWS8tHRornbpCJ1QF6p/MaxKqCLDrkP8zHx4+ibfZygIhALWvJdoKxDWfy/UXb+A9FQWFgtqEWYTlxBHeoPaTr+Or"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"datalanche","email":"contact@datalanche.com"},"maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}]}},"readme":"json-bignum\n===========\n\nNode.js JSON replacement which handles 64-bit integers and arbitrary-precision decimals. It is a modified version of [Douglas Crockford's JSON library](https://github.com/douglascrockford/JSON-js). Although it can handle 64-bit integers and arbitrary-precision decimals, it is slower than the built-in JSON functions.\n\n## Install\n\n $ npm install json-bignum\n\n## Usage\n\n### parse()\n\n```js\nvar bignumJSON = require('json-bignum');\n\nvar obj = bignumJSON.parse('{ \"decimal\": -9223372036854775807.4237482374983253298159 }');\n```\n\n### stringify()\n\n```js\nvar bignumJSON = require('json-bignum');\n\nvar obj = {\n bigint: new bignumJSON.BigNumber('92233720368547758074237482374983253298159'),\n decimal: new bignumJSON.BigNumber('-9223372036854775807.4237482374983253298159'),\n};\n\nconsole.log(bignumJSON.stringify(obj));\n```\n\n### BigNumber\n\nThe ```BigNumber``` class simply stores the number as a string. It does not support arithmetic, but if you need that here are some excellent libraries.\n\n* [BigDecimal.js](https://github.com/iriscouch/bigdecimal.js): a literal port of Java's ```BigInteger``` and ```BigDecimal``` classes.\n* [bigint](https://github.com/substack/node-bigint): Big integer arithmetic using GMP.\n* [bignum](https://github.com/justmoon/node-bignum): Big integer arithmetic using OpenSSL.\n\n```js\n// example using BigDecimal.js\n\nvar bignumJSON = require('json-bignum');\nvar bigdecimal = require('bigdecimal');\n\nvar jsonStr = '{\"normal\":-922337203.234,\"big\":-9223372036854775807.4237482374983253298159}';\nvar jsonObj = bignumJSON.parse(jsonStr);\n\nvar a = new bigdecimal.BigDecimal(jsonObj.normal.toString());\nvar b = new bigdecimal.BigDecimal(jsonObj.big.toString());\nvar sum = a.add(b);\n\njsonObj.sum = new bignumJSON.BigNumber(sum.toString());\n\nconsole.log(bignumJSON.stringify(jsonObj));\n```\n\n## Caveats\n\nIt is not recommended to mix calls to ```JSON``` and ```bignumJSON```. For example, ```JSON.stringify()``` does not know how to parse ```BigNumber```.\n\n## Benchmark\n\nBelow shows the result of the benchmark on my machine.\n\n $ node benchmark.js\n 10000 calls of JSON.parse(): 26.746847 ms\n 10000 calls of JSON.stringify(): 20.824071 ms\n 10000 calls of bignumJSON.parse() with bignums in JSON: 221.945307 ms\n 10000 calls of bignumJSON.parse() without bignums in JSON: 150.626292 ms\n 10000 calls of bignumJSON.stringify() with bignums in JSON: 64.166056 ms\n 10000 calls of bignumJSON.stringify() without bignums in JSON: 61.860016 ms\n","maintainers":[{"name":"datalanche","email":"contact@datalanche.com"}],"time":{"modified":"2022-06-19T06:11:56.284Z","created":"2013-03-22T22:04:32.263Z","0.0.1":"2013-03-22T22:04:32.947Z","0.0.2":"2013-03-25T16:19:49.033Z","0.0.3":"2014-04-18T19:21:16.186Z"},"author":{"name":"Datalanche, Inc.","url":"https://www.datalanche.com"},"repository":{"type":"git","url":"https://github.com/datalanche/json-bignum.git"},"homepage":"https://github.com/datalanche/json-bignum","readmeFilename":"README.md","bugs":{"url":"https://github.com/datalanche/json-bignum/issues"}}