Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comment-json

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comment-json - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

5

package.json
{
"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": {

41

README.md
# 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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc