Socket
Socket
Sign inDemoInstall

read-json-sync

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    read-json-sync

Read and parse a JSON file synchronously


Version published
Weekly downloads
156K
increased by86.58%
Maintainers
1
Install size
6.02 kB
Created
Weekly downloads
 

Readme

Source

read-json-sync

npm version Build Status Coverage Status

A Node.js module to read and parse a JSON file synchronously

const readJsonSync = require('read-json-sync');

readJsonSync('package.json'); //=> {name: 'read-json-sync', version: '1.0.0', ...}

Node.js built-in require and import can do almost the same thing, but this module doesn't cache results.

Installation

Use npm.

npm install read-json-sync

API

const readJsonSync = require('read-json-sync');

readJsonSync(path [, options])

path: string Buffer URL (JSON filename) or integer (file descriptor)
options: Object string (fs.readFile options or an encoding of the file)
Return: any (parsed JSON data)

It automatically ignores the leading byte order mark.

// with-bom.json: '\uFEFF{"a": 1}'

JSON.parse('\uFEFF{"a": 1}'); // throws a SyntaxError

readJsonSync('with-bom.json'); //=> {a: 1}

License

ISC License © 2017 - 2018 Shinnosuke Watanabe

Keywords

FAQs

Last updated on 16 Dec 2018

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