{"name":"jsonfile","version":"6.0.0","description":"Easily read/write JSON files.","repository":{"type":"git","url":"git+ssh://git@github.com/jprichardson/node-jsonfile.git"},"keywords":["read","write","file","json","fs","fs-extra"],"author":{"name":"JP Richardson","email":"jprichardson@gmail.com"},"license":"MIT","dependencies":{"universalify":"^0.2.0","graceful-fs":"^4.1.6"},"optionalDependencies":{"graceful-fs":"^4.1.6"},"devDependencies":{"mocha":"^5.2.0","rimraf":"^2.4.0","standard":"^12.0.1"},"main":"index.js","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"mocha"},"gitHead":"1639f64b9596294440dee7ec9366cc6e30b65334","bugs":{"url":"https://github.com/jprichardson/node-jsonfile/issues"},"homepage":"https://github.com/jprichardson/node-jsonfile#readme","_id":"jsonfile@6.0.0","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","dist":{"integrity":"sha512-M4yexIvXXRwOw3TQILHJSxJa6i+efkRRIGmCYJoXy2sH91EovJihfIcryUzCG3uHgrcx9n3O/Hm8oY/uTdR59A==","shasum":"14c51dd6fceb667d3beeba1d164a23aad619bb51","tarball":"http://registry-npm.ywwl.com/jsonfile/download/jsonfile-6.0.0.tgz","fileCount":6,"unpackedSize":18586,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU+h+CRA9TVsSAnZWagAAVlcP/0ZFDWAf315Mf90ZMO9U\nsauZMqqpgL67367h0jzi2fxiaP7vist0DamdC+7FW06/9ncvd0gLnFf9ySIC\nCE5HmBXEGF5MzwbNzipBZxIWkVS8FXOih7d20Rljeogw2DtX6HlQ5DHMZCm+\nB5h5wNuNiTNUwQ9+HhQJYqMiMweCcX0e/zuOUUnpC/rzdG3qVeCw913670xQ\ndvdDQ12NiUrfMFCtagGLJSK+b5kVHF7huAMuQncGlEvOq2dMGKiVy372BH1C\nEACWM/pv5aH0sU2qH3Q5p3UxbO9lZAfAJF1x4pNCNfPdTAnsyXu0atyYt1SG\nYyn82/ero89x2UBwK6OBlf/dTrmKxu3hGcZpuYms0CT0QcN9a3sLxSEC5+hP\ndousOqmOCL1fVbsrUEAlcbq8RxWDG/1zCx8jAFZZ1nofcZtmNS1orR1mOZFt\nw0SuhsDgm+1Wx2DpNPMoxO8aOswtAhliukNyXCN5//rzBUarHV56v3o/UYXE\nAHnetTmabHz2HNDLxKPt0dKkcGofiEObbHuxmwo3rwU1veQQmoIJ/s7npO1P\nZTQQ03gtnmkKTFdLJCiefCdNUcQAogTA6Oj9aQtExmMPTu1skiHX0JOLHMtM\n4td2NGJO6Kzi6Fcz7NS8TSrUHRBL3Cm0wIKOZpXWV/jFMtd0CLSV+RQsegoq\ndFbz\r\n=a1WV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqrTSHGb2S/3kBwR3CC1BOaCVyMwneAdgs2P9CfY8fKgIhALKCk3k7+nmndj2mWAirWeDdK22So7hNxTxKz/S7N/FZ"}],"size":5621,"noattachment":false,"key":"/jsonfile/-/jsonfile-6.0.0.tgz"},"maintainers":[{"name":"jprichardson","email":"jprichardson@gmail.com"},{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsonfile_6.0.0_1582557309691_0.9814688137061665"},"_hasShrinkwrap":false,"readme":"Node.js - jsonfile\n================\n\nEasily read/write JSON files in Node.js. _Note: this module cannot be used in the browser._\n\n[![npm Package](https://img.shields.io/npm/v/jsonfile.svg?style=flat-square)](https://www.npmjs.org/package/jsonfile)\n[![build status](https://secure.travis-ci.org/jprichardson/node-jsonfile.svg)](http://travis-ci.org/jprichardson/node-jsonfile)\n[![windows Build status](https://img.shields.io/appveyor/ci/jprichardson/node-jsonfile/master.svg?label=windows%20build)](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)\n\n<a href=\"https://github.com/feross/standard\"><img src=\"https://cdn.rawgit.com/feross/standard/master/sticker.svg\" alt=\"Standard JavaScript\" width=\"100\"></a>\n\nWhy?\n----\n\nWriting `JSON.stringify()` and then `fs.writeFile()` and `JSON.parse()` with `fs.readFile()` enclosed in `try/catch` blocks became annoying.\n\n\n\nInstallation\n------------\n\n    npm install --save jsonfile\n\n\n\nAPI\n---\n\n* [`readFile(filename, [options], callback)`](#readfilefilename-options-callback)\n* [`readFileSync(filename, [options])`](#readfilesyncfilename-options)\n* [`writeFile(filename, obj, [options], callback)`](#writefilefilename-obj-options-callback)\n* [`writeFileSync(filename, obj, [options])`](#writefilesyncfilename-obj-options)\n\n----\n\n### readFile(filename, [options], callback)\n\n`options` (`object`, default `undefined`): Pass in any [`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).\n  - `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.\n  If `false`, returns `null` for the object.\n\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\njsonfile.readFile(file, function (err, obj) {\n  if (err) console.error(err)\n  console.dir(obj)\n})\n```\n\nYou can also use this method with promises. The `readFile` method will return a promise if you do not pass a callback function.\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\njsonfile.readFile(file)\n  .then(obj => console.dir(obj))\n  .catch(error => console.error(error))\n```\n\n----\n\n### readFileSync(filename, [options])\n\n`options` (`object`, default `undefined`): Pass in any [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).\n- `throws` (`boolean`, default: `true`). If an error is encountered reading or parsing the file, throw the error. If `false`, returns `null` for the object.\n\n```js\nconst jsonfile = require('jsonfile')\nconst file = '/tmp/data.json'\n\nconsole.dir(jsonfile.readFileSync(file))\n```\n\n----\n\n### writeFile(filename, obj, [options], callback)\n\n`options`: Pass in any [`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.\n\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, function (err) {\n  if (err) console.error(err)\n})\n```\nOr use with promises as follows:\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj)\n  .then(res => {\n    console.log('Write complete')\n  })\n  .catch(error => console.error(error))\n```\n\n\n**formatting with spaces:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2 }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n**overriding EOL:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2, EOL: '\\r\\n' }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n\n**disabling the EOL at the end of file:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { spaces: 2, finalEOL: false }, function (err) {\n  if (err) console.log(err)\n})\n```\n\n**appending to an existing JSON file:**\n\nYou can use `fs.writeFile` option `{ flag: 'a' }` to achieve this.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/mayAlreadyExistedData.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFile(file, obj, { flag: 'a' }, function (err) {\n  if (err) console.error(err)\n})\n```\n\n----\n\n### writeFileSync(filename, obj, [options])\n\n`options`: Pass in any [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj)\n```\n\n**formatting with spaces:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2 })\n```\n\n**overriding EOL:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\\r\\n' })\n```\n\n**disabling the EOL at the end of file:**\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/data.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { spaces: 2, finalEOL: false })\n```\n\n**appending to an existing JSON file:**\n\nYou can use `fs.writeFileSync` option `{ flag: 'a' }` to achieve this.\n\n```js\nconst jsonfile = require('jsonfile')\n\nconst file = '/tmp/mayAlreadyExistedData.json'\nconst obj = { name: 'JP' }\n\njsonfile.writeFileSync(file, obj, { flag: 'a' })\n```\n\nLicense\n-------\n\n(MIT License)\n\nCopyright 2012-2016, JP Richardson  <jprichardson@gmail.com>\n","publish_time":1582557309828,"_cnpm_publish_time":1582557309828,"dist-tags":{"latest":"6.2.1"}}