[英]How can I format JSON document in Visual Studio Community 2019?
I tried Ctrl + K , Ctrl + D , but it only works for *.cs files.我试过Ctrl + K , Ctrl + D ,但它只适用于 *.cs 文件。 JSON file has no errors and it isn't big, but when I press Ctrl + K , Ctrl + D it says the command is unavailable.
JSON文件没有错误,也不大,但是当我按Ctrl + K , Ctrl + D时,它说命令不可用。 I tried some other combos that I've found in the internet but they don't work at all.
我尝试了一些我在互联网上找到的其他组合,但它们根本不起作用。 I also don't have text editor options for JSON.
我也没有 JSON 的文本编辑器选项。 Do I have to install something additionally for them to appear?
我是否必须额外安装一些东西才能出现?
I have Visual Studio Community 2019 16.4.4 and Windows 10 x64.我有 Visual Studio Community 2019 16.4.4 和 Windows 10 x64。
You could copy your code into a blank JSON file using the menus.您可以使用菜单将代码复制到空白 JSON 文件中。 I'm using Microsoft Visual Studio Community 2019 Version 16.8.5.
我正在使用 Microsoft Visual Studio Community 2019 版本 16.8.5。
File -->New-->File-->Web-->JSON File文件-->新建-->文件-->Web-->JSON文件
Then you can right click and choose Format Document.然后您可以右键单击并选择格式化文档。
None of the above worked for me.以上都不适合我。
Instead反而
ALT + SHIFT + F
did the job!完成了任务!
Ctrl + K , Ctrl + D is short key for formatting code in Visual Studio, but you need to have a web module (such as Node.js or ASP.NET) installed to format JSON. Ctrl + K , Ctrl + D是 Visual Studio 中格式化代码的快捷键,但是你需要安装一个 web 模块(例如 Node.js 或 ASP.NET)来格式化 JSON。
Modify or Installing Components in Visual Studio 在 Visual Studio 中修改或安装组件
首先 CTRL+E 然后按 D 键。
Ctrl+K, Ctrl+D works for me in VS2019 My file has the .json extension. Ctrl+K,Ctrl+D 在 VS2019 中适用于我我的文件具有 .json 扩展名。 I'm using Json.Net in my project as well.
我也在我的项目中使用 Json.Net。
If you're having problems, there are a few packages you could import to do it through code .如果您遇到问题,您可以通过代码导入一些包来解决问题。 See:
看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.