Reputation: 85
I have this example file (example.json):
{"test": {"name": "testName"}}
Then, in my js file I import like this:
import testJson from "./example.json"
When I type:
testJson.
I want suggestions to appear in the IDE (preferably in VS Code).
How can I accomplish this?
Upvotes: 1
Views: 3513
Reputation: 65313
You don't need any extensions for this.
JSON imports are not supported in every module system so you need to tell VS Code that such imports are valid. To do this, in your jsconfig file, just add:
"resolveJsonModule": true
This will not only let you auto complete json import paths, but also give you proper intellisense for the import.
VS Code 1.44+ also automatically enables resolveJsonModule
in all JS files that do not belong to a jsconfig
:
Again though, if you have a jsconfig or tsconfig you'll need to explicitly set "resolveJsonModule": true
Upvotes: 1
Reputation: 4915
Use Node JSON Autocomplete it will add autocomplete in vscode.
Upvotes: 2