DEV Community

Galdin Raphael
Galdin Raphael

Posted on

1

How to post json with comments?

Using a json codeblock expects strictly valid JSON:

{
  "Email": { // <-- settings grouped under "Email"
    "ClientKey": "xxx",
    "ClientSecret": "xxx"
  }
}
Enter fullscreen mode Exit fullscreen mode

I tried jsonc and json5, both don't seem to be supported. Anyway to get dev.to to play nice with commented json without marking it as javascript?

Top comments (3)

Collapse
 
isherwood profile image
Clint Buhs • Edited

It's not a spiffy solution, but you might just have to add keys to your object just for the purpose of commenting and prefix the values with double slashes. My only other thought is to use multiple code blocks, alternating between json and js as needed.

Collapse
 
ben profile image
Ben Halpern

javascript?

Collapse
 
behitek profile image
Hieu Nguyen

You can comment in json like this:

{
  "Email": {
    "Comment": "settings grouped under \"Email\""
    "ClientKey": "xxx",
    "ClientSecret": "xxx"
  }
}
Enter fullscreen mode Exit fullscreen mode

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay