Socket
Socket
Sign inDemoInstall

load-json-file

Package Overview
Dependencies
8
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    load-json-file

Read and parse a JSON file


Version published
Weekly downloads
18M
decreased by-9.2%
Maintainers
1
Install size
97.0 kB
Created
Weekly downloads
 

Readme

Source

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');

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

API

loadJsonFile(filePath, [options])

Returns a promise for 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.

  • write-json-file - Stringify and write JSON to a file atomically

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 06 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc