简体   繁体   English

如何让Visual Studio获取高亮.json源代码?

[英]How can I get Visual Studio to source highlight .json source code?

How can I get VS to source highlight .json source code? 我怎样才能获得VS来源高亮.json源代码? I'd also like to have it have some of the same key-bindings that normal JavaScript enjoys. 我也想让它拥有一些普通JavaScript所享有的相同键绑定。 In a way all I'd really need/want is a way to have Visual Studio recognize a .json file as a .js file (I think). 在某种程度上,我真正需要/想要的是让Visual Studio将.json文件识别为.js文件(我认为)。 Is this possible? 这可能吗?

Try to use Visual Studio Extension TextHighlighter: 尝试使用Visual Studio扩展TextHighlighter:

VS 2010: TextHighlighterExtension VS 2010: TextHighlighterExtension
VS 2012: TextHighlighterExtension12 VS 2012: TextHighlighterExtension12

Great news! 好消息!

In CTP2 of Visual Studio 2013 Update 2 that was added a New JSON project item and editor Visual Studio 2013 Update 2的CTP2中添加了一个新的JSON项目项和编辑器

One more post New JSON editor features in Visual Studio 2013 Update 2 CTP2 在Visual Studio 2013 Update 2 CTP2中再发布一个新的JSON编辑器功能

Visual Studio中的JSON编辑器支持数据类型

VS2013中的JSON编辑器向错误列表添加警告

VS2013 Update 2 CTP2中的JSON编辑器

Navigate starting at the top menu bar, 从顶部菜单栏开始导航,

TOOLS --> Options --> Text Editor --> File Extensions 工具 - >选项 - >文本编辑器 - >文件扩展名

Here you can add json as an entry, however, the Script Editor will not work at all, you can use Visual C++ editor experience which will provide very basic highlighting until Microsoft can get with the program and add some basic JSON support. 在这里,您可以添加json作为条目,但是, Script Editor根本不起作用,您可以使用Visual C++编辑器体验,这将提供非常基本的突出显示,直到Microsoft可以使用该程序并添加一些基本的JSON支持。

The problem is that a json file isn't valid javascript. 问题是json文件无效javascript。 (A file containing just a javascript literals without an assignment is invalid.) So while it will highlight, Visual Studio will be convinced your file's wrong, and (personally) I find that more annoying than the lack of highlighting. (只包含没有赋值的javascript文字的文件是无效的。)因此,虽然它会突出显示,但Visual Studio将确信您的文件是错误的,并且(个人而言)我发现比缺少突出显示更烦人。

There is this project: http://jsonviewer.codeplex.com/ but that seems old and not currently maintained. 有这个项目: http//jsonviewer.codeplex.com/但看起来很旧,目前还没有维护。 (Also it seems like it's just a visualizer, not a syntax highlighting plugin.) (此外,它似乎只是一个可视化工具,而不是语法高亮插件。)

I'm currently look for a good plugin for this, or possibly writing one. 我目前正在寻找一个好的插件,或者可能写一个。

Into the menus Tools .. Options .. Text Editor .. File Extensions 进入菜单工具..选项..文本编辑器..文件扩展名

Add the JSON extension and choose to use the Script Editor 添加JSON扩展并选择使用脚本编辑器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何使用Chrome内置JSON解析器读取Chrome源代码中的JSON文件 - How can i read a json file in chromium source code using chromium in-built json parser 将Web性能测试(Visual Studio)与JSON和数据源一起使用 - Using Web Performance Tests (Visual Studio) with JSON and a data source 如何从Logstash上的JSON日志中提取源主机名 - how can i extract source hostnames from JSON logs on logstash 如何在Windows任务栏上显示JSON源中的值? - How can I show values from a JSON source on the Windows Taskbar? 如何将我自己的错误消息和智能感知添加到visual-studio-code 中的JSON 文件中 - how can I add my own error messagess and intellisense to a JSON file in visual-studio-code 如何在Java中使用JSON发送源代码? - How to send a source code using JSON in java? 如何让Visual Studio 2013使用自定义JSON模式? - How can I get Visual Studio 2013 to use a custom JSON schema? 如何在 Visual Studio Code 中控制 JSON 的格式样式? - How do I control the formatting style of JSON in Visual Studio Code? 如何在带有注释的Json中获取请求的源IP? - How to get Source IP of Request in Json with Annotation? 如何在C#/ Visual Studio中包含源而不是库? - How to include source instead of a library in C# / Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM