17

While changing any setting in Visual Studio I'm getting an error like this:

  Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.

In the settings.json There is a problem as:

     Expected Comma JsonC(514)

Error Code:

enter image description here

Akif
  • 7,098
  • 7
  • 27
  • 53
Satyam Shukla
  • 171
  • 1
  • 1
  • 3
  • 3
    Please edit your question by adding the settings.json file. The issue is about a missing comma. – Akif Nov 06 '20 at 06:50
  • 2
    You missed a comma in your `settings.json`. Please copy and paste your `settings.json` content to this question – AnsonH Nov 06 '20 at 10:55
  • 2
    Paste your `settings.json` file into an online json linter - it'll probably show exactly where the issue is. – Mark Nov 06 '20 at 16:14
  • Correcting errors pointed out by vscode on `settings.json` solved it. – JinSnow Jul 25 '22 at 16:45

4 Answers4

11

I suggest to validate your JSON in an online JSON validator like jsonlint for better info where the problem lies.

Also, as mentioned in this SO post and this SO post, that leading 0's on a number would also cause this kind of issue.

If you have a number, don't ever store it with leading zeroes. If you have a value that needs to have a leading zero, don't treat it as a number, but as a string. Store it with quotes around it.

Here is an example:

Invalid

{
  "attribute": "// numeroConta",
  "operator": "=",
  "value": 0030152201

}

enter image description here

Valid

{
  "attribute": "// numeroConta",
  "operator": "=",
  "value": "0030152201"
}

enter image description here

Please provide your settings.json if this is not the case.

MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65
  • All cool and nice... but what about files that you have NOT edited? I'm just having this error, and it's the second time I used this editor. I didn't even knew where to find these JSON files. – runlevel0 Aug 31 '21 at 11:15
4

One of the most common causes for this is presence of comments inside JSON file. While vscode itself loads config with json-with-comments format, the sync part fails and when you use the GUI to configure settings it fails to update the settings.json file, even if you will not see any error/warning reported on the file.

sorin
  • 161,544
  • 178
  • 535
  • 806
1

In my case I had to open settings.json and add , on the end of

{
    "workbench.colorTheme": "Default Light+",
    "workbench.colorCustomizations": {
        "editorError.foreground":   "#00000000",
        "editorWarning.foreground": "#00000000",
        "editorInfo.foreground":    "#00000000"
    },
Hrvoje
  • 13,566
  • 7
  • 90
  • 104
0

In my case, I had a comma at the end of the main curly brackets, but VS Code wasn't alerting to it specifically:

{
    ...
}, // <---
Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76