SyntaxError:意外的令牌)

时间:2015-07-13 17:38:19

标签: html json syntax-error

我发布这个是因为我之前没有看过这个确切的问题,而且我以前的帖子没有运气。 我正在创建一个名为Exhibit的应用程序布局,它在时间轴上显示我的数据。 html代码是为Exhibit构建的。 我的数据存储在JSON文件中。我用JLint检查了它,它似乎是正确的格式。但是我对我的JSON文件抛出了上述错误。

这是我的JSON文件中的一个对象。

{

"items" : [
    {
        "url" :        "http:\/\/twitter.com\/acarvin\/statuses\/32815014167445504",
        "uri" :        "file:\/\/\/C:\/Users\/david\/Documents\/Work\/Exhibit\/CAR\/item#%40acarvin%3A%20AlJaz%20showing%20huge%20crowds%20rushing%20down%20a%20Cairo%20street.%20\'It%20is%20an%20intense%20battle%20here.\'%20%23jan25",
        "time" :       "2011-02-02 14:58:03",
        "date" :       "2005",
        "action" :     "reporting",
        "hour" :       "14:58:03",
        "role" :       "reporter",
        "username" :   "acarvin",
        "keywords" :   [
            "crowd",
            " battle",
            " al jazeera"
        ],
        "ignoretime" : "2\/2\/2011 14:58:03",
        "type" :       "Item",
        "label" :      "@acarvin: AlJaz showing huge crowds rushing down a Cairo street. \'It is an intense battle here.\' #jan25",
        "gender" :     "male",
        "location" :   "talaat harb",
        "origin" :     "file:\/\/\/C:\/Users\/david\/Documents\/Work\/Exhibit\/CAR\/hands-on.html#%40acarvin%3A%20AlJaz%20showing%20huge%20crowds%20rushing%20down%20a%20Cairo%20street.%20\'It%20is%20an%20intense%20battle%20here.\'%20%23jan25"
    }
          ]
 }

谁能看到可能发生的事情? 注意:我在调用时将数据类型指定为application / json。

1 个答案:

答案 0 :(得分:0)

您的字符串中有几个以\'形式存在的无效转义符。虽然这些在JavaScript字符串中有效(无论是单引号还是双引号),但它们都不是有效的JSON。在JSON中,'只是'

有了这些,字符串将无法验证。删除无关的\后,它将会删除。 (我用http://jsonlint.com确认。)

相关问题