Support for comments in JSON
See original GitHub issueWhat’s your take on supporting single-line and block comments in JSON? Several popular projects (e.g. TypeScript) allow comments in JSON configuration files:
{
"compilerOptions": {
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// ...
}
Although the JSON spec doesn’t include comments, I think it would be helpful to have support for them in Prism; comments can be particularly helpful in technical blog posts.
What do you think? I’ll be happy to send a PR! 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Can comments be used in JSON? - Stack Overflow
JSON does not support comments natively, but you can make your own decoder or at least preprocessor to strip out comments ...
Read more >JSON Comment Example — How to Comment in JSON Files
If you're having trouble adding comments to your JSON file, there's a good reason: JSON doesn't support comments.
Read more >Multiple ways to write JSON Comments - W3schools.io
As per Standard JSON rules, There is no official support for Comments in JSON content. JSON contains keys and values as per standard...
Read more >Comments in JSON - Stack Abuse
Unfortunately the JSON specification does not allow for comments in the same way that many programming languages do. So while JSON is often ......
Read more >Using Comments in JSON with Node.js and ... - Techiediaries
As you might be aware of, JSON doesn't support comments! But as programmers, we are used to add comments so in this article,...
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 Free
Top 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
Sure, I’ll be happy to! Just wanted to run this by everyone first. I’ll send a PR tonight!
Closing this issue, now that support has landed in https://github.com/PrismJS/prism/pull/1595.