@eloquentiastudios/commentable-json
v1.0.2
Published
```bash # Using npm $ npm install @eloquentiastudios/commentable-json
Downloads
4
Readme
commentable-json
Quick Start
Installation
# Using npm
$ npm install @eloquentiastudios/commentable-json
# Using yarn
$ yarn add @eloquentiastudios/commentable-json
# Using pnpm
$ pnpm i @eloquentiastudios/commentable-json
Example Usage
import { parseJsonWithComments, stringifyJsonWithComments } from '@eloquentiastudios/commentable-json';
const objectToBeCommented = {
foo: 'bar',
baz: 'qux',
};
const commentsForObject = {
_: 'This is a comment for the entire object',
foo: 'This is a comment for the foo property',
baz: 'This is a comment for the baz property',
}
const jsonWithComments: typeof objectToBeCommented = stringifyJsonWithComments(objectToBeCommented, commentsForObject);
// Parse the JSON with comments to get the original object
const parsedObject = parseJsonWithComments(jsonWithComments);
Supported Node.js Versions
Should work on any Node.js version that supports ESM modules (i.e. type="module"
in package.json
).
License
Uses the MIT license.
See LICENSE for more information.