json - 对 JSON 文件使用 vscode 内置颜色选择器

标签 json visual-studio-code color-picker

我试图让内置颜色选择器以与 vscode 自己的 settings.json 文件相同的方式处理 json (webmanifest) 文件,以在十六进制值旁边显示内联颜色块。
之前的一个线程建议创建一个模式并使用 format: color在这个架构中。我已经尝试过文档中的示例 https://code.visualstudio.com/docs/languages/json在 settings.json 中,虽然它在我的 webmanifest 文档中提供了代码智能感知,但它仍然没有显示颜色值。

"json.schemas": [
    {
        "fileMatch": ["*.webmanifest"],
        "url": "https://json.schemastore.org/web-manifest",
        "properties": {
            "theme_color": {
                "format": "color"
            }
        }
    }
]
我找不到 vscode 的内置 json 模式来查看它是如何完成的。任何帮助将不胜感激。汤姆
更新
这在包含 type:object 后有效一对。不过还有很多工作要做。
"json.schemas": [
    {   
         "fileMatch": ["*.webmanifest"],
         "schema": {
             "type": "object",
             "properties": {
                 "theme_color" : {
                     "type": "string",
                     "description": "toolbar colour: hex only",
                     "format": "color-hex"
                 }
             }
         }
    }
]

最佳答案

这对我来说效果很好。我只更改了 *.json 文件的扩展名。 “fileMatch”采用一个数组,因此您可以根据需要添加多种文件类型。
关于为什么需要这样做的文档:
https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings

关于json - 对 JSON 文件使用 vscode 内置颜色选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64795908/

相关文章:

javascript - JavaScript 中的高级路由

javascript - 如何修复具有特殊字符的 JSON 字符串中的验证错误

Angular 翻译插件未启动

javascript - D3 : Bar chart coloring

css - Angular 渐变与 CSS Webkit 渐变?

json - 如何在 Angular 5 中使用嵌套的 JSON 数据填充多级 Kendo Treeview

python - MySQL、JSON、Python、Django - 完全错误

python - "Python: Current File (Integrated Terminal)"-Visual Studio 代码

windows - VSCode 终端之前的命令

delphi - 如何获得任何背景图像的相反颜色