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?
Use Node JSON Autocomplete it will add autocomplete in vscode.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.