Validating JSON data

In VS Code, if I have a JSON file open, it will automatically highlight areas that do not validate. For example, if double quotes are missing from a field, VSCode will mark it in red. On Replit, there is no feedback given when JSON is invalid, and I end up sending students to an external validator. I wonder if there is a way to turn on validation / syntax check for JSON.

Hi @harold.sikkema welcome to the community!

This isn’t a feature available in replit at the moment so your solution to use an external validator is the best option.

You can suggest improvements / features using the share feedback option when in any Repl :

image

This feature of highlighting code is made through lsp(language server protocol), and lsp are supported by replit

Which language(template) do you use with your students in replit?

I’m using HTML, CSS, JS for the language. Is it possible to change LSP settings to allow JSON highlighting in this context?


Click on the three dots on the files tab

Will appear the hidden files, click on the file .replit

Click Switch to code editor

Add this code to the end of the file:

[languages.json]
pattern = "**/*.json

[languages.json.languageServer]
start = "vscode-json-language-server --stdio"

Look, ultimately, the file .replit is unstable, this may exclude all of the other languages server, so if this happen, just overcopy the code bellow into the file, wait some seconds(to autosave), and close the .replit file

hidden=[".config"]

# hosting is currently hardcoded for this language
# [hosting]
# route = "/"
# directory= "/"

[nix]
channel = "stable-21_11"

[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config"]

[languages]

[languages.html]
pattern = "**/*.html"

[languages.html.languageServer]
start = "vscode-html-language-server --stdio"

[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx,*.mjs,*.cjs}"

[languages.javascript.languageServer]
start = "typescript-language-server --stdio"

[languages.css]
pattern = "**/{*.less,*.scss,*.css}"

[languages.css.languageServer]
start = "vscode-css-language-server --stdio"

[languages.json]
pattern = "**/*.json"

[languages.json.languageServer]
start = "vscode-json-language-server --stdio"

Great suggestion @nullmetry !

1 Like