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

cjson

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjson

cjson - Commented JavaScript Object Notation. It is a json loader, which parses only valid json files, but with comments enabled. Useful for loading configs.

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is cjson?

The cjson npm package is a JSON parser that supports comments and more relaxed JSON syntax. It allows you to parse JSON files that include comments, trailing commas, and other non-standard JSON features.

What are cjson's main functionalities?

Parse JSON with comments

This feature allows you to parse JSON strings that include comments. The comments are ignored during parsing, making it easier to include explanations or notes within your JSON files.

const cjson = require('cjson');
const jsonData = cjson.parse('{"key": "value" // This is a comment
}');
console.log(jsonData);

Stringify JSON with comments

This feature allows you to convert a JavaScript object into a JSON string while preserving comments. This can be useful for generating JSON files that include comments for documentation purposes.

const cjson = require('cjson');
const jsonObject = { key: 'value' };
const jsonString = cjson.stringify(jsonObject, null, 2, { comments: true });
console.log(jsonString);

Load JSON file with comments

This feature allows you to load and parse a JSON file that includes comments. The comments are ignored during parsing, making it easier to maintain and understand your JSON files.

const cjson = require('cjson');
const jsonData = cjson.load('path/to/your/file.json');
console.log(jsonData);

Other packages similar to cjson

Keywords

FAQs

Package last updated on 07 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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