JSPM

  • Created
  • Published
  • Downloads 6321452
  • Score
    100M100P100Q202844F
  • License MIT

Parse and stringify JSON file with domments

Package Exports

  • comment-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (comment-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

comment-json NPM version Build Status Dependency Status

Parse and stringify JSON file with domments.

Install

$ npm install comment-json --save

Usage

package.json:

{
  // package name
  "name": "comment-json"
}
var json = require('comment-json');
var obj = json.parse(fs.readFileSync('package.json').toString());
console.log(obj);
// ->
// {
//   "// name": "// package name",
//   name: "comment-json"
// }

json.stringify(obj, null, 2); // Will be the same as package.json

json.parse(string, [reviver])

The arguments are the same as the vanilla JSON.parse.

json.stringify(object, [replacer], [space])

The arguments are the same as the vanilla JSON.stringify.

And it does the similar thing as the vanilla one, and also stringify the "// abc"-like property into comments if the "abc" property is found.

License

MIT