require-strip-json-comments

2.0.0 • Public • Published

require-strip-json-comments Build Status

Require .json files with comments.

For advanced JSON syntax I recomend using require-json5, which can load JSON with trailing commas, unquoted keys, hex numbers, comments, and more.

Install

npm i require-strip-json-comments

Usage

  1. Load a JSON file which contains comments
var requireJSON = require('require-strip-json-comments');
var config = requireJSON("./config.json");
  1. Parse a JSON string which contains comments
var requireJSON = require('require-strip-json-comments');
var config = requireJSON.parse('{"name": /*a very important option*/ "value"}');
  1. Replace require()
require('require-strip-json-comments').replace_require();
var config = require("./config");
  1. Replace JSON.parse()
require('require-strip-json-comments').replace_JSON();
var config = JSON.parse('{"name": /*a very important option*/ "value"}');
  1. Replace require() and JSON.parse()
require('require-strip-json-comments').replace();
// ...

/require-strip-json-comments/

    Package Sidebar

    Install

    npm i require-strip-json-comments

    Weekly Downloads

    16,600

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    7.38 kB

    Total Files

    8

    Last publish

    Collaborators

    • duzun