comment-json
Advanced tools
Comparing version 2.0.6 to 2.0.7
{ | ||
"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 @@ |
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
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
24993
8
571
313