试图弄清楚为什么我无法解析我的JSON文件

时间:2015-02-03 07:21:21

标签: javascript ajax json file syntax-error

我无法弄清楚我的错误在这个JSON文件中的位置。我知道有一个地方,因为当试图解析它。我得到错误Uncaught SyntaxError:意外的令牌J我想知道你们是否可以帮助我看看你是否看到我的问题,我一直在研究这个问题,我仍然无法找到错误。来自社区的人帮我找到一个,但它仍然无法工作我正在解析JSON,如此

var obj = JSON.parse("JSON.json");

这是JSON

{
"Subbackground":{"direction": "to bottom", "Color1": " #a90329 0%", "Color2": "#8f0222 44%", "Color3": "#6d0019 100%"},
"ButtonBG": {"direction":"to bottom", "Color1": "#216332 5%", "Color2": "#5cbf2a 100%"},
"ButtonHov": {"direction":"to bottom", "Color1": "#5cbf2a 5%", "Color2": "#216332 100%"},
"textColor":"#ffffff",
"BorderSubColor":"#a90329",
"ButtonShadow":"#2f6627",
"ButtonBShawdow":"#3dc21b",
"BorderMain":"#18ab29",
"Sub1":"steaknshake", "urlPath1":"http://www.steaknshake.com/",
"Sub2":"steaknshake", "urlPath2":"http://www.steaknshake.com/",
"Sub3":"steaknshake", "urlPath3":"http://www.steaknshake.com/",
"Sub4":"steaknshake", "urlPath4":"http://www.steaknshake.com/",
"Sub5":"steaknshake", "urlPath5":"http://www.steaknshake.com/",
"Sub6":"steaknshake", "urlPath6":"http://www.steaknshake.com/",
"Sub7":"steaknshake", "urlPath7":"http://www.steaknshake.com/",
"Sub8":"steaknshake", "urlPath8":"http://www.steaknshake.com/",
"Sub9":"steaknshake", "urlPath9":"http://www.steaknshake.com/",
"Sub10":"steaknshake", "urlPath10":"http://www.steaknshake.com/",
"Pizza":"steaknshake", "urlPathP":"http://www.steaknshake.com/",
"Berger":"steaknshake", "urlPathB":"http://www.steaknshake.com/",
"Lobster":"steaknshake", "urlPathL":"http://www.steaknshake.com/",
"Chicken":"steaknshake", "urlPathCN":"http://www.steaknshake.com/",
"Shrimp":"steaknshake", "urlPathSP":"http://www.steaknshake.com/",
"BLT":"steaknshake", "urlPathB":"http://www.steaknshake.com/",
"Salmon":"steaknshake", "urlPathSN":"http://www.steaknshake.com/",
"CatFish":"steaknshake", "urlPathCF":"http://www.steaknshake.com/",
"Steak":"steaknshake", "urlPathSK":"http://www.steaknshake.com/",
"Crab":"steaknshake", "urlPathCB":"http://www.steaknshake.com/"
}

1 个答案:

答案 0 :(得分:0)

在最后一行,您尚未关闭urlPath值附近的引号:

"Crab":"steaknshake", "urlPath":"http://www.steaknshake.com/"
                                                            ^ was missing

为了将来参考,您可以使用jsonlint.com来测试有效的JSON并查找错误。