Skip to content
Read and parse a JSON file
JavaScript
Find file
Latest commit 7014502 @sindresorhus Merge pull request #4 from ntwb/patch-1
Travis CI: Test on Node.js v4.x.x and v5.x.x
Failed to load latest commit information.
.editorconfig init
.gitattributes init
.gitignore init
.travis.yml Travis CI: Test on Node.js v4.x.x and v5.x.x
index.js init
license init
package.json remove now moot XO ignore
readme.md ES2015ify tests
test.js remove now moot XO ignore

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 that resolves to the parsed JSON.

loadJsonFile.sync(filepath)

Returns the parsed JSON.

Related

License

MIT © Sindre Sorhus

Something went wrong with that request. Please try again.