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

Trying to figure out why i cannot parse my JSON file

本文关键字:我的 JSON 文件 弄清楚 为什么      更新时间:2023-09-26

我无法弄清楚我的错误在这个 JSON 文件中的位置。 我知道某处有一个,因为在尝试解析它时。 我收到错误 未捕获的语法错误:意外的令牌 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/"
}

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

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

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