question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for comments in JSON

See original GitHub issue

What’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:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mariusschulzcommented, Oct 24, 2018

Sure, I’ll be happy to! Just wanted to run this by everyone first. I’ll send a PR tonight!

0reactions
mariusschulzcommented, Nov 7, 2018

Closing this issue, now that support has landed in https://github.com/PrismJS/prism/pull/1595.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found