javascript - 解析 '..."许可证“: "ISC", 附近时,JSON 中位置 351 处的意外标记}

标签 javascript json node.js npm

我是 JavaScript 和 JSON 新手,我正在尝试上传我的 NPM 包。由于某种原因,当我尝试发布它时收到此错误:

Unexpected token } in JSON at position 351 while parsing near '..."license": "ISC",

},
"bugs": {
"e..."

这是我的 JSON 文件。

{
"name": "M-P-Formulas-JS",
"version": "1.0.0",
"description": "The M-P-Formulas package for JavaScript. This package allows the user to use math and physics formulas such as the Pythagorean Theorem.",
"main": "mpformulasJS.js",
"author": {
    "email": "8b21espq@gmail.com",
    "name": "Jeff Lockhart",
    "url": "",
    "license": "ISC",
},
"bugs": {
    "email": "8b21espq@gmail.com",
},
"dependencies": {
    "Math": "",
},
"keywords": [
    "mpformulas",
    "mpformulasjs",
    "m-p-formulas-js",
    "math",
    "physics",
    "formulas",
    "module",
    "package",
 ],
}

我什至运行了npm cache clean,但是,由于它不起作用,我可以确定我的代码是错误的。如果是这样,我该如何解决这个问题?

谢谢。

最佳答案

删除多余的逗号,因为它是关闭对象之前的最后一项。它会导致无效的 JSON。

"license": "ISC", // <--- Remove this comma

"bugs": {
    "email": "8b21espq@gmail.com", // <--- Remove this comma
}

JS 对象和 JSON 是不同的。例如,这是一个有效的 JS 对象,但无效的 JSON :

bugs : {
    email : "8b21espq@gmail.com",
}

有效的 JSON 为:

"bugs": {
    "email": "8b21espq@gmail.com"
}

关于javascript - 解析 '..."许可证“: "ISC", 附近时,JSON 中位置 351 处的意外标记},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48063239/

相关文章:

Node.js mongclient 批量大小

javascript - 使用本地存储来存储AngularJS数据

java - 将天数转换为周数的数学公式是什么

javascript - 泰勒瑞克 : preventing postback with RadButton confirm dialog

javascript - 搜索与搜索和替换

python - 在 Python 中序列化用户定义的类

javascript - 如何在不改变 redux 状态的情况下增加帖子?

Python 将 JSON 文件保存为 UTF-8

json - 使用 jq 以特定键 boolean == true 提取 JSON 数组中的值?

javascript - 使 React 图片库对 SEO 友好的策略