Read and parse a JSON file
JavaScript
Latest commit 49620f1 May 1, 2016 @sindresorhus 2.0.0
Failed to load latest commit information.
.editorconfig tweaks May 1, 2016
.gitattributes init Sep 2, 2015
.gitignore init Sep 2, 2015
.travis.yml tweaks Apr 30, 2016
index.js tweaks Apr 30, 2016
license init Sep 2, 2015
package.json 2.0.0 May 1, 2016
readme.md tweaks Apr 30, 2016
test.js tweaks Apr 30, 2016

readme.md

load-json-file Build Status

Read and parse a JSON file

Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors.

Install

$ npm install --save load-json-file

Usage

const loadJsonFile = require('load-json-file');

loadJsonFile('foo.json').then(json => {
    console.log(json);
    //=> {foo: true}
});

API

loadJsonFile(filepath)

Returns a promise for the parsed JSON.

loadJsonFile.sync(filepath)

Returns the parsed JSON.

Related

License

MIT © Sindre Sorhus