Installations
npm install require-json5
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
16.4.2
NPM Version
7.18.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
duzun
Download Statistics
Total Downloads
1,942,542
Last Day
1,749
Last Week
1,749
Last Month
18,608
Last Year
355,356
GitHub Statistics
3 Stars
12 Commits
2 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
1.3.0
Package Id
require-json5@1.3.0
Unpacked Size
13.91 kB
Size
4.76 kB
File Count
13
NPM Version
7.18.1
Node Version
16.4.2
Total Downloads
Cumulative downloads
Total Downloads
1,942,542
Last day
0%
1,749
Compared to previous day
Last week
-46.8%
1,749
Compared to previous week
Last month
-6%
18,608
Compared to previous month
Last year
-16.1%
355,356
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
3
require-json5 ![Build Status](https://travis-ci.com/duzun/require-json5.svg?branch=master)
Require JSON5 files in node - a better JSON for the JSNext era
JSON5 is more human friendly, can contain comments, trailing commas, unquoted keys and more!
Install
1npm i -S require-json5
Usage
Include the lib:
1const requireJSON5 = require('require-json5');
- Require a JSON5 file
1let config = require("./config.json5"); 2 // or w/o the extension, when "./config.json5" exists and there is no "./config.json", nor "./config.js" 3let config = require("./config");
- Explicitly load a
.json
file in JSON5 format
1let config = requireJSON5("./config.json");
- Load a .js file as JSON5 format.
This is useful if you don't like the
.json5
file extension and prefer to keep JSON5 in.js
files.
1let config = requireJSON5("./config.js");
- Parse a JSON5 string
1let config = requireJSON5.parse('{ name: /*a very important option*/ "value" }');
- Use JSON5 for all
require(.json)
calls
1require('require-json5').replace(); 2let config = require("./config"); // can be config.json, config.json5 or config.js
- Restore the original
require(.json)
1require('require-json5').restore();
Example of JSON5
The following is a contrived example, but it illustrates most of the features:
1{ 2 foo: 'bar', 3 while: true, 4 5 this: 'is a \ 6multi-line string', 7 8 // this is an inline comment 9 here: 'is another', // inline comment 10 11 /* this is a block comment 12 that continues on another line */ 13 14 hex: 0xDEADbeef, 15 half: .5, 16 delta: +10, 17 to: Infinity, // and beyond! 18 19 finally: 'a trailing comma', 20 oh: [ 21 "we shouldn't forget", 22 'arrays can have', 23 'trailing commas too', 24 ], 25}
For more details on the JSON5
format see the json5 library.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More