Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Dec 19, 2023 via pnpm

json5 1.0.1

JSON for humans.
Package summary
Share
0
issues
0
licenses
Package created
27 May 2012
Version published
18 Mar 2018
Maintainers
2
Total deps
0
Direct deps
0
License
MIT

Issues

0
This package has no issues

Frequently Asked Questions

What does json5 do?

JSON5 is a JavaScript library and an extension to the widely-used JSON file format, with the aim of making it easier to write and maintain manually - particularly in the context of configuration files. It's not designed for machine-to-machine communication, for which regular JSON should still be used. The JSON5 Data Interchange Format is a superset of JSON, meaning all valid JSON files will also be valid JSON5 files. This extension introduces several features from ECMAScript 5.1 (ES5) to JSON, and is also a strict subset of ES5, hence all valid JSON5 files will also be valid ES5.

How do you use json5?

Using JSON5 involves a simple installation process via npm, followed by requiring or importing the library into your JavaScript files. For Node.js, you start by installing it with the command npm install json5. Then, if you're using CommonJS, you can include it in your file using const JSON5 = require('json5'), or if using Modules, use import JSON5 from 'json5'.

With JSON5 successfully imported, you can start utilizing it's API. For instance, JSON5.parse(text[, reviver]) can be used to parse a JSON5 string and construct the JavaScript value or object it describes. As a usage example:

const JSON5 = require('json5')

const jsonString = `{
  hello: 'world',
  list: ['item1', 'item2', 'item3',]
}`

const jsonObject = JSON5.parse(jsonString)
console.log(jsonObject)

You can also use JSON5 functionalities on a browser. For instance, including it in your HTML file from a CDN like so:

<script src="https://unpkg.com/json5@2/dist/index.min.js"></script>

This will create a global JSON5 variable for use in your client-side JS scripts.

Where are the json5 docs?

The in-depth documentation for JSON5, including a detailed explanation of the JSON5 format, its API and CLI usage, as well as contribution guidelines, can be found directly on the official GitHub repository (https://github.com/json5/json5). The formal JSON5 Interchange Format specification is also accessible at the external dedicated site (https://spec.json5.org/).