JSON.parse:JSON 数据的第 61 行第 2 列 object 中的 属性 值之后的数据结束
JSON.parse: end of data after property value in object at line 61 column 2 of the JSON data
我正在移植 Google Chrome 扩展以成为 Firefox add-on。我最终让它成为一个临时的 add-on,但它需要有一个 ID 以便我将其保存在文件中(这是我想要做的)。我已经过去了,但现在我无法关闭 manifest.json。当我尝试关闭 json 时,Firefox 给我在标题中看到的错误。
尝试了很多不同形式的括号闭合,例如:
]
}
]}
}
等等。
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
如标题所述,我在右括号中收到错误。请原谅我忽略了这件非常愚蠢的事情,我在 Lua 中编程,而 Web 开发不是我的专长。这段代码应该是重现问题所需的全部代码,但我还是这方面的新人,所以如果需要更多,请告诉我。我也是堆栈溢出的新手,所以我想按照要求将它保持在最低限度。
它应该能够加载到 Firefox 上,但它给了我标题中看到的错误消息。
整个 json 文件在这里:
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*",
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
您应该在此处查看 manifest.json 的规范:https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json
我建议使用 JSON 编辑工具,例如 https://jsoneditoronline.org/ 来构建您的 JSON,这样您就不会忘记添加正确的括号对...
现在我看到了整个文件,似乎 "gecko": 对象缺少一个 },"browser_specific_settings":
对象缺少一个 }
这是所有括号都匹配的文件。
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*"
}
},
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
编辑:请使用其他答案。我看错了规范。
编辑 - 更好的答案现在已经提供了 JSON
这里正在工作 JSON 由我在下面链接的解析器验证:
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*",
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
}
}
从根本上说,您的问题归结为缩进不一致,因此很难判断问题出在哪里。实际问题是您在文件末尾缺少 2 个额外的右大括号 }
。您可以使用我在下面的原始答案中链接的解析器来尝试帮助您调试这些问题。
提供完整 JSON 之前的原始答案
如果您将您提供的最后一段代码输入到本网站,您可以查看它是否有效:http://json.parser.online.fr/剧透:它说是。这应该是您的第一个线索,表明问题实际上并不像您目前认为的那样与最后一块有关。作为参考,这是我复制到该解析器中的内容:
{
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
根据您复制的内容来判断,因为您没有给我们完整的 JSON 文件,我相信您在本节上方的某处包含了一个额外的右括号 }
。这是因为如果你注意你复制的内容的缩进:
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
结束列表括号 ]
与结束对象大括号 }
具有相同的缩进。当然,这可能与您将代码复制到 Whosebug 的方式有关,但由于您没有向我们提供文件的其余部分,我没有任何其他线索可以解决。
我正在移植 Google Chrome 扩展以成为 Firefox add-on。我最终让它成为一个临时的 add-on,但它需要有一个 ID 以便我将其保存在文件中(这是我想要做的)。我已经过去了,但现在我无法关闭 manifest.json。当我尝试关闭 json 时,Firefox 给我在标题中看到的错误。
尝试了很多不同形式的括号闭合,例如:
]
}
]}
}
等等。
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
如标题所述,我在右括号中收到错误。请原谅我忽略了这件非常愚蠢的事情,我在 Lua 中编程,而 Web 开发不是我的专长。这段代码应该是重现问题所需的全部代码,但我还是这方面的新人,所以如果需要更多,请告诉我。我也是堆栈溢出的新手,所以我想按照要求将它保持在最低限度。
它应该能够加载到 Firefox 上,但它给了我标题中看到的错误消息。
整个 json 文件在这里:
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*",
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
您应该在此处查看 manifest.json 的规范:https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json
我建议使用 JSON 编辑工具,例如 https://jsoneditoronline.org/ 来构建您的 JSON,这样您就不会忘记添加正确的括号对...
现在我看到了整个文件,似乎 "gecko": 对象缺少一个 },"browser_specific_settings":
对象缺少一个 }这是所有括号都匹配的文件。
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*"
}
},
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
编辑:请使用其他答案。我看错了规范。
编辑 - 更好的答案现在已经提供了 JSON
这里正在工作 JSON 由我在下面链接的解析器验证:
{ "browser_specific_settings": {
"gecko": {
"id": "ihegfgnkffeibpmnajnoiemkcmlbmhmi",
"strict_min_version": "42.0",
"strict_max_version": "*",
"manifest_version": 2,
"name": "Crunchyroll HTML5",
"version": "0.14.4",
"description": "A fully fledged HTML5 player for Crunchyroll.",
"author": "Jeppe Rune Mortensen <jepperm@gmail.com>",
"icons": {
"16": "assets/icon16.png",
"32": "assets/icon32.png",
"48": "assets/icon48.png",
"64": "assets/icon64.png",
"96": "assets/icon96.png",
"128": "assets/icon128.png"
},
"background": {
"scripts": [
"vendor/browser-polyfill.min.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"*://www.crunchyroll.com/*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch.js",
"content-script.js"
],
"run_at": "document_start"
},
{
"all_frames": true,
"matches": [
"*://www.crunchyroll.com/affiliate_iframeplayer*"
],
"js": [
"vendor/browser-polyfill.min.js",
"patch-worker.firefox.js",
"content-script.js"
]
}
],
"web_accessible_resources": [
"vendor/JavascriptSubtitlesOctopus/*",
"fonts/*"
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
}
}
从根本上说,您的问题归结为缩进不一致,因此很难判断问题出在哪里。实际问题是您在文件末尾缺少 2 个额外的右大括号 }
。您可以使用我在下面的原始答案中链接的解析器来尝试帮助您调试这些问题。
提供完整 JSON 之前的原始答案
如果您将您提供的最后一段代码输入到本网站,您可以查看它是否有效:http://json.parser.online.fr/剧透:它说是。这应该是您的第一个线索,表明问题实际上并不像您目前认为的那样与最后一块有关。作为参考,这是我复制到该解析器中的内容:
{
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
根据您复制的内容来判断,因为您没有给我们完整的 JSON 文件,我相信您在本节上方的某处包含了一个额外的右括号 }
。这是因为如果你注意你复制的内容的缩进:
],
"permissions": [
"storage",
"*://www.crunchyroll.com/*",
"*://*.vrv.co/*",
"*://*.dlvr1.net/*",
"*://*.akamaized.net/*"
]
}
结束列表括号 ]
与结束对象大括号 }
具有相同的缩进。当然,这可能与您将代码复制到 Whosebug 的方式有关,但由于您没有向我们提供文件的其余部分,我没有任何其他线索可以解决。