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.

Add a JSONC language variant for "JSON with Comments"

See original GitHub issue

Similar to #406, which correctly points out that comments are not permitted in the JSON spec, can a new, very similar language be added that does permit comments and trailing commas?

This is often used in configuration files for (among other things) VS Code and Sublime Text. Github comparison of codefences for json versus jsonc:

[
    // The foo
    { "foo": [ "baz", 4, true ] },
    // The bar
    { "bar": [ "biff", 10, false ] },
]
[
    // The foo
    { "foo": [ "baz", 4, true ] },
    // The bar
    { "bar": [ "biff", 10, false ] },
]

Right now, I use javascript for these like #406 suggests, but it is much easier to discriminate keys and values with the JSON highlighting.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
joshgoebelcommented, Oct 5, 2019

Good catch. I just responded to that comment, we’ll see where it goes. 😃

0reactions
glen-84commented, Oct 6, 2019

@yyyc514 It would be nice to have that as an option. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
JSONC is a superset of JSON which supports comments
This is a Go-only implementation, but the concept is portable to any language (hint, hint). JSONC is a superset of JSON which supports...
Read more >
JSON With Commas and Comments - Nigel Tao
Summary: JWCC is a minimal extension to the widely used JSON file format with (1) optional commas after the final element of arrays...
Read more >
matlab-json-c - File Exchange - MathWorks
A simple parser for JSON with Comments written in MATLAB ... Hence the need for the not-quite-official JSON+C variant.
Read more >
JSON with Commas and Comments - Hacker News
Pretty much every language on the planet has JSON parser libraries ... anyway so you can put a few lines to ensure that...
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