Eclipse Neon Json editor - allow comments

筅森魡賤 提交于 2019-12-12 08:30:02

问题


Is it possible to allow comments in JSON file?

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?


回答1:


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.

I see two options:

  1. Use pseudo-comments as described here.
  2. 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

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.



来源:https://stackoverflow.com/questions/39655618/eclipse-neon-json-editor-allow-comments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!