comment-json
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "comment-json", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Parse and stringify JSON file with documments", | ||
@@ -18,3 +18,4 @@ "main": "index.js", | ||
"json-stringify", | ||
"json-parse" | ||
"json-parse", | ||
"parser" | ||
], | ||
@@ -21,0 +22,0 @@ "engines": { |
# comment-json [![NPM version](https://badge.fury.io/js/comment-json.svg)](http://badge.fury.io/js/comment-json) [![Build Status](https://travis-ci.org/kaelzhang/node-comment-json.svg?branch=master)](https://travis-ci.org/kaelzhang/node-comment-json) [![Dependency Status](https://gemnasium.com/kaelzhang/node-comment-json.svg)](https://gemnasium.com/kaelzhang/node-comment-json) | ||
<!-- description --> | ||
Parse and stringify JSON file with documments | ||
@@ -13,8 +13,45 @@ ## Install | ||
package.json: | ||
```json | ||
{ | ||
// package name | ||
"name": "comment-json" | ||
} | ||
``` | ||
```js | ||
var comment_json = require('comment-json'); | ||
var JSON = require('comment-json'); | ||
var obj = JSON.parse(fs.readFileSync('package.json').toString()); | ||
console.log(obj); | ||
// -> | ||
// { | ||
// "// name": { | ||
// pos: "top", | ||
// body: " 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`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). | ||
### JSON.stringify(object, [replacer], [space]) | ||
The arguments are the same as the vanilla [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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. | ||
### JSON.strip(string) | ||
Strips comments from `string`. | ||
## License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3817
3
57