Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure VS Code to enable code completion on .json files (jsonschema support)?

Tags:

In the Visual Stuido Code demo minute 28:57-29:20 and 30:20-31:10, some cool JSON code completion is shown.

Where and how do I add a schema for my JSON files to a project?

How does VS Code know which schema to use for a given .json file?

like image 344
Michael_Scharf Avatar asked May 05 '15 15:05

Michael_Scharf


People also ask

How do I make my json file readable in VS Code?

Formatting# You can format your JSON document using Ctrl+Shift+I or Format Document from the context menu.

Where is the settings json file for VS Code?

Similar to User Settings, Workspace Settings are also stored in a settings. json file, which you can edit directly via the Preferences: Open Workspace Settings (JSON) command. The workspace settings file is located under the . vscode folder in your root folder.

How add json to VS Code?

To open the User settings: Open the command palette (either with F1 or Ctrl + Shift + P ) Type "open settings" You are presented with two options, choose Open Settings (JSON)

How does json work with VS Code?

As VSCode handles JSON files natively, you can format your JSON document using Ctrl+Shift+I keyboard shortcut. Please note that the shortcut may varies between different operating systems. Alternatively, you can open the Command Palette (using Ctrl + Shift + P), and then searching for format document.


1 Answers

The association of JSON schemas to files is done in the settings (File, Preferences, User Settings or Workspace Settings), under the property 'json.schemas'.

This is an example how the JSON schema for bower is associated to the bower schema.

"json.schemas": [     {         "fileMatch": [             "/bower.json",             "/.bower.json"         ],         "url": "http://json.schemastore.org/bower"     },     ... 

You can also use schemas located in your workspace or define a schema right in the settings itself. Check https://code.visualstudio.com/docs/languages/json for examples.

like image 134
Martin Aeschlimann Avatar answered Sep 25 '22 11:09

Martin Aeschlimann