json - 如何将 javascript 格式应用于 .json 文件?

Eclipse 中的 Ctrl + Shift + F 热键可以格式化文件。它不适用于 .json 文件。如何让它发挥作用?

最佳答案

如果您还没有 JSON 编辑器插件,您将需要它。你可以找到它here

The JSON Editor is a simple plugin for the Eclipse IDE that provides: - Color text highlighting - An Outline Tree view - JSON validation - Text formatting - Text folding for the JSON data format.

如果热键仍然不起作用。看看他们网站here上的图片所示的菜单。

此外,我发现在过去,当前版本的格式化功能至少存在一个问题。 从他们的讨论site:

rlespinola 
2010-07-15 00:18:05 UTC
Using version 0.9.4, I do not see the option to "Format Text". Also, when I open a .json file, the outline view says "An outline is not available".

jdschulteis
2010-12-27 16:59:24 UTC
Using 0.9.4 on Helios, I also had "An outline is not available". I went to Window->Preferences->General->Editors->File Associations, selected '*.json' in the 'File types:' list, selected 'Json Editor' in the 'Associated editors:' list, and clicked 'Default'. I now get an outline, though it can be somewhat slow (6K line file).

编辑:

有几种方法可以添加插件。 Eclipse 建议使用 update manager . 试试 help > software updates > find and install

你可以看看here对于一些替代方法。

https://stackoverflow.com/questions/7541823/

相关文章:

c# - C# 中的 TimeSpan "pretty time"格式

java - 在碧 Jade 报告中将字符串格式化为货币格式

python - 无法编码/解码 pprint 输出

formatting - 如何在 Spring MVC 3.0 中显示格式化的 DateTime?

xml - Eclipse:保存时自动格式化 XML 文件

excel - 如何在 VBA 中检索工作表中格式化的 Excel 单元格值?

python - 并非所有参数都在字符串格式化期间转换

excel - 如何防止自动截断 Excel 单元格中的前导零

jquery - 格式化应该跨越多行的 jQuery 字符串

.net - 根据可用宽度和字体计算文本高度?