Reference a fixed JSON file #42
-
I’m following along the tree-view sample, and my goal is for the JSON file the tree view is created from to be hard coded into the extension (the path of a specific JSON file) such that regardless of which file is open the tree view is the same. Currently the code is dependent on the active editor being a JSON file, and I assumed it would be an easy proof of concept if I could hardcode the active editor to reference a specific path somewhere in the constructor but I haven't been able to figure it out. I'm fairly new to developing VS Code extensions (& typescript!), so any help would be great! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I suppose you are looking for customizing the
In your case, line 86 it the one responsible for that. Replace it with your custom JSON file and you are good to go. Hope this helps |
Beta Was this translation helpful? Give feedback.
I suppose you are looking for customizing the
parseTree
function, which in that sample, is responsible to load the JSON file from the active editor, as you can see:https://github.com/microsoft/vscode-extension-samples/blob/128179bd61c0e0a24322ea42d2003b6ace5bc94e/tree-view-sample/src/jsonOutline.ts#L81-L89
In your case, line 86 it the one responsible for that. Replace it with your custom JSON file and you are good to go.
Hop…