Jad*_*ias 17 eclipse formatting json indentation auto-indent
Eclipse中的Ctrl+ Shift+ F热键可以格式化文件.它不适用于.json文件.如何使它工作?
小智 16
如果你还没有它,你会想要获得JSON编辑器插件.你可以在这里找到它
JSON编辑器是Eclipse IDE的一个简单插件,它提供: - 颜色文本突出显示 - 大纲树视图 - JSON验证 - 文本格式化 - JSON数据格式的文本折叠.
如果热键仍然不起作用.就拿菜单下看看如图片所示,从他们的网站在这里
此外,我发现过去至少存在一个与当前版本格式化功能有关的问题.从他们的讨论网站:
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).
Run Code Online (Sandbox Code Playgroud)
编辑:
有几种方法可以添加插件.Eclipse建议使用更新管理器.尝试帮助>软件更新>查找并安装
你可以在这里寻找一些替代方法.
我使用Eclipse Luna(4.4.0)找到了两个选项.
使用JSON编辑器插件并定义快捷方式
使用Javascript开发插件与丑陋和恼人的解决方法
{"addressbook": {"name": "John Doe",
"address": {
"street": "5 Main Street", "city": "San Diego, CA", "zip": 91912
},
"phoneNumbers": [
"619 555-3452",
"664 555-4667"
]
}
}Run Code Online (Sandbox Code Playgroud)
var obj = {"addressbook": {"name": "John Doe",
"address": {
"street": "5 Main Street", "city": "San Diego, CA", "zip": 91912
},
"phoneNumbers": [
"619 555-3452",
"664 555-4667"
]
}
}Run Code Online (Sandbox Code Playgroud)