Feat: use JSON5 instead of JSON.parse for friendly JSON syntax
See original GitHub issue{
// comments
unquoted: 'and you can quote me on that',
singleQuotes: 'I can use "double quotes" here',
lineBreaks: "Look, Mom! \
No \\n's!",
hexadecimal: 0xdecaf,
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
positiveSign: +1,
trailingComma: 'in objects', andIn: ['arrays',],
"backwardsCompatible": "with JSON",
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
JSON5 – JSON for Humans | JSON5
This JavaScript library is a reference implementation for JSON5 parsing and serialization, and is directly used in many of the popular projects mentioned...
Read more >JSON parsing | Can I use... Support tables for HTML5, CSS3, etc
Method of converting JavaScript objects to JSON strings and JSON back to objects using JSON.stringify() and JSON.parse(). Usage % of. all users, all...
Read more >JSON.parse() - JavaScript - MDN Web Docs
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
Read more >Can comments be used in JSON? - Stack Overflow
No. JSON is data-only. If you include a comment, then it must be data too. You could have a designated data element called...
Read more >Json image viewer - Veiled Mirror
Beautify JSON online using this tool to format your json, json output, ... with an online Javascript parser, featuring tree view and syntax...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was not planning on using
require
for JSON files. I don’t think there’s a need.I am not interested in going down a rabbit hole to support “other flavors of json”. The request to parse multiple flavors of JS opens the door to more than enough flexibility, I think. And YAML provides opportunity for comments outside of JS files.
If there’s some strong argument about why JSON5 is a superior config format in common situations, not just an arbitrary personal preference, I’d consider reopening this issue.
i think there’s work toward using
require
instead of parsing the file as a string. We’ll then allow consumers to pass their own require function. This is mainly to support es modules but your use-case will be covered here as well.Anyway we can leave this issue open till that’s finished