Eclipse Neon Json编辑器-允许评论 [英] Eclipse Neon Json editor - allow comments
问题描述
是否可以在JSON文件中添加注释?
Is it possible to allow comments in JSON file?
我有一个JSON文件,其中注释行标记为 //
开头。 com.fasterxml.jackson.databind.ObjectMapper
正确读取了文件,但JSON编辑器将其标记为错误( 行的预期值:column
),整个项目都标记为错误。
是否可以只允许注释或禁用对一个文件的验证?
I have a JSON file with comment lines marked with //
on the beginning. The file is properly read by com.fasterxml.jackson.databind.ObjectMapper
, but JSON editor marks it as error (Expected value at row:column
) and whole project is marked with error.
Is it possible to allow comments or disable validation for one file only?
推荐答案
因为JSON格式非常简单,Eclipse的内置JSON验证无法对标记为错误的内容提供任何精细控制。
Because the JSON format is very simple, Eclipse's built-in JSON validation doesn't provide any granular control over what is marked as an error.
我看到两个选项:
- 使用伪注释如此处所述。
- 禁用该特定文件的JSON验证。
- 窗口>首选项>验证
- 在 Validator列表中,找到 JSON Validator,然后单击 ...在设置列中
- 添加排除组,然后为要让验证者忽略的特定文件添加规则
- Use pseudo-comments as described here.
- Disable JSON validation for that specific file.
- Window > Preferences > Validation
- In the 'Validator' list, find "JSON Validator" and click the '...' in the Settings column
- Add an exclude group, then add a rule for the specific file you want the validator to ignore
顺便说一句,JSON格式不支持任何注释符号。严格来说,该错误消息是正确的-但在这种情况下,您使用的解析器(杰克逊)被配置为允许某些不合规格的东西。
As an aside, the JSON format doesn't support any kind of comment notation. Strictly speaking, that error message is correct - but in this case the parser you're using (Jackson) is configured to allow something out-of-spec.
这篇关于Eclipse Neon Json编辑器-允许评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!