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 2.0.6 to 2.0.7

src/array.js

2

package.json
{
"name": "comment-json",
"version": "2.0.6",
"version": "2.0.7",
"description": "Parse and stringify JSON with comments. It will retain comments even when after saved!",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -25,2 +25,10 @@ [![Build Status](https://travis-ci.org/kaelzhang/node-comment-json.svg?branch=master)](https://travis-ci.org/kaelzhang/node-comment-json)

## Why?
There are many other libraries that can deal with JSON with comments, such as [json5](https://npmjs.org/package/json5), or [strip-json-comments](https://npmjs.org/package/strip-json-comments), but none of them can stringify the parsed object and return back a JSON string the same as the original content.
Imagine that if the user settings are saved in `${library}.json`, and the user has written a lot of comments to improve readability. If the library `library` need to modify the user setting, such as modifying some property values and adding new fields, and if the library uses `json5` to read the settings, all comments will disappear after modified which will drive people insane.
So, **if you want to parse a JSON string with comments, modify it, then save it back**, `comment-json` is your must choice!
## Install

@@ -55,3 +63,3 @@

stringify(obj, null, 2)
// Will be the same as package.json,
// Will be the same as package.json, Oh yeah! 😆
// which will be very useful if we use a json file to store configurations.

@@ -104,2 +112,5 @@ ```

console.log(parsed)
console.log(stringify(parsed, null, 2))
// 🚀 Exact as the content above! 🚀
```

@@ -106,0 +117,0 @@

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