read-json-sync
Read and parse a JSON file synchronously
Last updated 7 years ago by shinnn .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install read-json-sync 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.1                                ...           latest (7 years ago)

9 Versions

  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           8 years ago
  • 2.0.0-3                                ...           8 years ago
  • 2.0.0-2                                ...           8 years ago
  • 2.0.0-1                                ...           9 years ago
  • 2.0.0-0                                ...           9 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 4
Last Month 5
Dependencies (0)
None
Dev Dependencies (6)

Copyright 2013 - present © cnpmjs.org | Home |