load-json-file
Read and parse a JSON file
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install load-json-file 
SYNC missed versions from official npm registry.

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 load-json-file

Usage

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

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

API

loadJsonFile(filePath, options?)

Returns a Promise<unknown> with the parsed JSON.

loadJsonFile.sync(filepath, options?)

Returns the parsed JSON.

options

Type: object

beforeParse

Type: Function

Applies a function to the JSON string before parsing.

reviver

Type: Function

Prescribes how the value originally produced by parsing is transformed, before being returned. See the JSON.parse docs for more.

Related


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Current Tags

  • 6.2.0                                ...           latest (a year ago)

13 Versions

  • 6.2.0                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.3.0                                ...           a year ago
  • 5.2.0                                ...           a year ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.0                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 9,908
This Week 60,469
This Month 540,217
Last Day 50,561
Last Week 296,584
Last Month 1,217,165
Dependencies (4)
Dev Dependencies (3)
Dependents (404)

Copyright 2014 - 2016 © taobao.org |