githubEdit

load-json-file

Read and parse a JSON file

Strips UTF-8 BOMarrow-up-right, uses graceful-fsarrow-up-right, and throws more helpful JSON errorsarrow-up-right.

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.

License

MIT © Sindre Sorhusarrow-up-right

Last updated