load-json-file
Read and parse a JSON file
Last updated 7 months 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 (7 months ago)

13 Versions

  • 6.2.0                                ...           7 months ago
  • 6.1.0                                ...           8 months ago
  • 6.0.0                                ...           9 months ago
  • 5.3.0                                ...           10 months ago
  • 5.2.0                                ...           a year ago
  • 5.1.0                                ...           a year ago
  • 5.0.0                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 3,220
This Week 17,510
This Month 605,222
Last Day 8,038
Last Week 71,279
Last Month 925,901
Dependencies (4)
Dev Dependencies (3)
Dependents (359)

Copyright 2014 - 2016 © taobao.org |