Read and parse a JSON file synchronously
npm install read-json-sync


A Node.js module to read and parse a JSON file synchronously
``javascript
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.
``
npm install read-json-sync
`javascript`
const readJsonSync = require('read-json-sync');
path: string Buffer URL (JSON filename) or integer (file descriptor) Object
options: string (fs.readFile options or an encoding of the file) any
Return: (parsed JSON data)
It automatically ignores the leading byte order mark.
`javascript
// with-bom.json: '\uFEFF{"a": 1}'
JSON.parse('\uFEFF{"a": 1}'); // throws a SyntaxError
readJsonSync('with-bom.json'); //=> {a: 1}
``
ISC License © 2017 - 2018 Shinnosuke Watanabe