最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IntelliJ IDEA: json file syntax - Stack Overflow

programmeradmin0浏览0评论

I am using IntelliJ IDEA 14 for a web project, where I want to keep a file a.js containing a JSON object. The content of the a.js is

{
    "ac" : "abc",
    "d" : 4,
    "_constants": {}
}

While editing this file, IntelliJ keeps reminding me that this file has syntactic errors. It makes a hints after "ac", "d" and "_constants", before the semicolon, saying "Expecting newline or semicolon".

Does not IntelliJ IDEA accept a file containing a JSON object as a legitimate javascript file?

I am using IntelliJ IDEA 14 for a web project, where I want to keep a file a.js containing a JSON object. The content of the a.js is

{
    "ac" : "abc",
    "d" : 4,
    "_constants": {}
}

While editing this file, IntelliJ keeps reminding me that this file has syntactic errors. It makes a hints after "ac", "d" and "_constants", before the semicolon, saying "Expecting newline or semicolon".

Does not IntelliJ IDEA accept a file containing a JSON object as a legitimate javascript file?

Share Improve this question edited Feb 25, 2015 at 14:34 gefei asked Feb 25, 2015 at 14:24 gefeigefei 19.9k9 gold badges54 silver badges70 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

IntelliJ has a separate file type for JSON files. It will be applied if you rename your file from a.js to a.json.

You can add file pattern to your settings

Settings->Editor->File Types->Json

For example "json-config-*.js"

发布评论

评论列表(0)

  1. 暂无评论