{ "_args": [ [ { "raw": "jsonfile@^3.0.0", "scope": null, "escapedName": "jsonfile", "name": "jsonfile", "rawSpec": "^3.0.0", "spec": ">=3.0.0 <4.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/fs-extra" ] ], "_from": "jsonfile@>=3.0.0 <4.0.0", "_id": "jsonfile@3.0.1", "_inCache": true, "_location": "/jsonfile", "_nodeVersion": "7.8.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/jsonfile-3.0.1.tgz_1499266104031_0.6694869988132268" }, "_npmUser": { "name": "ryanzim", "email": "opensrc@ryanzim.com" }, "_npmVersion": "4.2.0", "_phantomChildren": {}, "_requested": { "raw": "jsonfile@^3.0.0", "scope": null, "escapedName": "jsonfile", "name": "jsonfile", "rawSpec": "^3.0.0", "spec": ">=3.0.0 <4.0.0", "type": "range" }, "_requiredBy": [ "/fs-extra" ], "_resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", "_shasum": "a5ecc6f65f53f662c4415c7675a0331d0992ec66", "_shrinkwrap": null, "_spec": "jsonfile@^3.0.0", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/fs-extra", "author": { "name": "JP Richardson", "email": "jprichardson@gmail.com" }, "bugs": { "url": "https://github.com/jprichardson/node-jsonfile/issues" }, "dependencies": { "graceful-fs": "^4.1.6" }, "description": "Easily read/write JSON files.", "devDependencies": { "mocha": "2.x", "rimraf": "^2.4.0", "standard": "^6.0.8" }, "directories": {}, "dist": { "shasum": "a5ecc6f65f53f662c4415c7675a0331d0992ec66", "tarball": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz" }, "gitHead": "51ec1e27d0426a107464cccab688e35ec64fc08d", "homepage": "https://github.com/jprichardson/node-jsonfile#readme", "keywords": [ "read", "write", "file", "json", "fs", "fs-extra" ], "license": "MIT", "main": "index.js", "maintainers": [ { "name": "jprichardson", "email": "jprichardson@gmail.com" }, { "name": "ryanzim", "email": "opensrc@ryanzim.com" } ], "name": "jsonfile", "optionalDependencies": { "graceful-fs": "^4.1.6" }, "readme": "Node.js - jsonfile\n================\n\nEasily read/write JSON files.\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\"Standard\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)\n\n`options` (`object`, default `undefined`): Pass in any `fs.readFile` 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\nvar jsonfile = require('jsonfile')\nvar file = '/tmp/data.json'\njsonfile.readFile(file, function(err, obj) {\n console.dir(obj)\n})\n```\n\n\n### readFileSync(filename, [options])\n\n`options` (`object`, default `undefined`): Pass in any `fs.readFileSync` 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\nvar jsonfile = require('jsonfile')\nvar file = '/tmp/data.json'\n\nconsole.dir(jsonfile.readFileSync(file))\n```\n\n\n### writeFile(filename, obj, [options], callback)\n\n`options`: Pass in any `fs.writeFile` 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`.\n\n\n```js\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/data.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFile(file, obj, function (err) {\n console.error(err)\n})\n```\n\n**formatting with spaces:**\n\n```js\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/data.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFile(file, obj, {spaces: 2}, function(err) {\n console.error(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\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/mayAlreadyExistedData.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFile(file, obj, {flag: 'a'}, function (err) {\n console.error(err)\n})\n```\n\n### writeFileSync(filename, obj, [options])\n\n`options`: Pass in any `fs.writeFileSync` 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`.\n\n```js\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/data.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFileSync(file, obj)\n```\n\n**formatting with spaces:**\n\n```js\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/data.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFileSync(file, obj, {spaces: 2})\n```\n\n**appending to an existing JSON file:**\n\nYou can use `fs.writeFileSync` option `{flag: 'a'}` to achieve this.\n\n```js\nvar jsonfile = require('jsonfile')\n\nvar file = '/tmp/mayAlreadyExistedData.json'\nvar obj = {name: 'JP'}\n\njsonfile.writeFileSync(file, obj, {flag: 'a'})\n```\n\n### spaces\n\nGlobal configuration to set spaces to indent JSON files.\n\n**default:** `null`\n\n```js\nvar jsonfile = require('jsonfile')\n\njsonfile.spaces = 4\n\nvar file = '/tmp/data.json'\nvar obj = {name: 'JP'}\n\n// json file has four space indenting now\njsonfile.writeFile(file, obj, function (err) {\n console.error(err)\n})\n```\n\nNote, it's bound to `this.spaces`. So, if you do this:\n\n```js\nvar myObj = {}\nmyObj.writeJsonSync = jsonfile.writeFileSync\n// => this.spaces = null\n```\n\nCould do the following:\n\n```js\nvar jsonfile = require('jsonfile')\njsonfile.spaces = 4\njsonfile.writeFileSync(file, obj) // will have 4 spaces indentation\n\nvar myCrazyObj = {spaces: 32}\nmyCrazyObj.writeJsonSync = jsonfile.writeFileSync\nmyCrazyObj.writeJsonSync(file, obj) // will have 32 space indentation\nmyCrazyObj.writeJsonSync(file, obj, {spaces: 2}) // will have only 2\n```\n\n\nLicense\n-------\n\n(MIT License)\n\nCopyright 2012-2016, JP Richardson \n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+ssh://git@github.com/jprichardson/node-jsonfile.git" }, "scripts": { "lint": "standard", "test": "npm run lint && npm run unit", "unit": "mocha" }, "version": "3.0.1" }