Home > other >  I cannot fix an error in a JSON settings file in VS code
I cannot fix an error in a JSON settings file in VS code

Time:08-28

I'm a learner programmer. I wanted to prevent the VS code from opening the previous projects / session. I entered its settings to prevent window restore. But I cannot change it because there is some kind of error. I run the JSON file through a JSON validator, just as I read somewhere (but I know nothing about JSON yet).

The validator found a mistake in the syntax of the first line. But I don't know how to fix it. For me it has the same pattern as other lines:

Error:

"diffEditor.wordWrap": "on",
  "editor.wordWrap": "on",
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.fontSize": 16,
  "security.workspace.trust.untrustedFiles": "open",
  "workbench.iconTheme": "Monokai Pro Icons",
  "todohighlight.defaultStyle": {},
  "workbench.colorTheme": "Monokai Dimmed",
  "emmet.syntaxProfiles": {

    "html": {
        //if element created is more than 2, it will break to new line for each element
        "inline_break": 2,
    }
}
//  the message from the validator
Error: Parse error on line 1:
...diffEditor.wordWrap": "on","editor.word
-----------------------^
Expecting 'EOF', '}', ',', ']', got ':'

But it's not clear for me at all.

CodePudding user response:

The two surrounding braces were missing:

{
    "diffEditor.wordWrap": "on",
     "editor.wordWrap": "on",
     "editor.formatOnPaste": true,
     "editor.formatOnSave": true,
     "editor.defaultFormatter": "esbenp.prettier-vscode",
     "editor.fontSize": 16,
     "security.workspace.trust.untrustedFiles": "open",
     "workbench.iconTheme": "Monokai Pro Icons",
     "todohighlight.defaultStyle": {},
     "workbench.colorTheme": "Monokai Dimmed",
     "emmet.syntaxProfiles": {
        "html": {
            //if element created is more than 2, it will break to new line for each element
            "inline_break": 2,
        }
     }
}

CodePudding user response:

I found the answer. I managed to reset the JSON file in VS Code settings by simply deleting its content and by restarting the VS code.

  •  Tags:  
  • json
  • Related