Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VS Code, disable error "Comments are not permitted in JSON"

People also ask

How do I allow comments in JSON Vscode?

Click on the letters JSON at the bottom in the right corner. Type jsonc to use the JSON with Comments file association.

Why JSON comments are not allowed?

Reasons to use JSONC and not to allow comments in the regular JSON files are: It will separate your file from real JSON files. It is not going to bite you in the back when you add comment to a file where validation has to be applied, but you forget to remove comments because there is no error message.

Are comments permitted in JSON?

If you're having trouble adding comments to your JSON file, there's a good reason: JSON doesn't support comments.

How do I fix Vscode JSON?

json file. You can open the settings. json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P). Once the file is open in an editor, delete everything between the two curly braces {} , save the file, and VS Code will go back to using the default values.


Follow these steps:

  1. Click on the letters JSON in the bottom right corner. (A drop-down will appear to "Select the Language Mode.")
  2. Select "Configure File Association for '.json'..."

enter image description here

  1. Type jsonc and press Enter.

enter image description here

If you only want to disable the error message for a single file, skip step #2.


Add this to your User Settings:

"files.associations": {
    "*.json": "jsonc"
},

If you don't already have a user settings file, you can create one. Hit Ctrl+, or +, (that's a comma) to open your settings, then hit the Open Settings (JSON) button in the upper right. It looks like this: the button's icon; a page with a little curved arrow over it


Just rename file to test.jsonc

Reasons to use JSONC and not to allow comments in the regular JSON files are:

  1. It will separate your file from real JSON files
  2. It is not going to bite you in the back when you add comment to a file where validation has to be applied, but you forget to remove comments because there is no error message.
  3. It is going to work out of the box on any setup without "tuning" someone else's VS Code.