Closed
Labels
feature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersjsonJSON support issuesverification-neededVerification of issue is requestedverifiedVerification succeeded
Milestone
Description
- VSCode Version: 1.20.1
- OS Version: Win 10
Does this issue occur when all extensions are disabled?: Yes
I've tried asking this on stackoverflow and gitter without success. I have a project with (among other things) lots of .json files. This is the .vscode/settings.json file:
{
"json.schemas": [
{
"fileMatch": [
"*.json"
],
"url": "https://path/to/schema.json"
}
]
}The problem is that this matches all .json files in the project, but I need it to match only *.json files in the root directory. What can I put in fileMatch to enable this, or can this not be done with the file matching?
Reacted by Jakub Čábera, SPGoding, Luca Fabbri, Eskild Diderichsen and Marcel Gongora
Metadata
Metadata
Assignees
Labels
feature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersjsonJSON support issuesverification-neededVerification of issue is requestedverifiedVerification succeeded
Activity
RMacfarlane commentedon Feb 21, 2018
Does
"./*.json"work?stkb commentedon Feb 21, 2018
Unfortunately not, and btw I had it slightly wrong in my first post (now edited)
"*.json"matches all .json file in all directories."/*.json"matches only .json files 1+ levels down"./*.json"doesn't seem to match any files.aeschli commentedon Jun 25, 2018
The patterns currently just match against the end of the full file path. The matcher is not aware of the workspace folder.
A workaround for you is to add the name of the root folder to the pattern, e.g.
myroot/*.json, but of course, that's not ideal.We would need something like a `${workspaceFolder} variable to do this properly.
4 remaining items
soreavis commentedon Jul 17, 2026
Martin Aeschlimann (@aeschli) I'd like to take this. The matcher lives in vscode-json-languageservice, but there's a second piece: the single-folder
.vscode/settings.jsoncase passesfolderUrias undefined to the service (jsonClient.ts), so the client has to hand the folder over for anything workspace-relative to work there.On syntax — you mentioned
${workspaceFolder}, and mgzenitech suggested a leading/anchoring to the folder root like .gitignore. I prototyped the leading-/version: a contained change inFilePatternAssociation, fully backward compatible (bare*.jsonunchanged; only a leading-/-with-folderUri pattern, which is a no-op today, changes), with 5 new unit tests and the full suite green — plus 40+ edge cases I ran against the matcher (special-character folder names, encoded and unicode paths, remote schemes, exclusions). Either way the folder should be matched by prefix rather than expanded into the glob — the glob has no escape, so a folder namedmy[proj]would break an injected pattern.Which would you rather, leading
/or${workspaceFolder}? Once you pick I'll open both PRs (service + client).aeschli commentedon Jul 20, 2026
${workspaceFolder}would be my favorite. It would be expanded on the client. The server shouldn't need to know about workspace folders. So the server API stays unchangedsoreavis commentedon Jul 20, 2026
Martin Aeschlimann (@aeschli) done — #326706.
json.schemassettings are collected; the server stays untouched, so it's one PR instead of the two I offered.One caveat for review: the folder is matched textually inside the pattern and the service's glob has no escape, so folder names containing
[,{or?won't match — details in the PR.JSON - support ${workspaceFolder} in json.schemas fileMatch patterns