javascript - JSON 文件中缺少分号,VSCode 无法识别问题行
问题描述
我正在尝试将这个小 JSON 文件导入另一个网页
"data": [
{
"id": 72053645,
"name": "Weather Report",
"type": "Flip Effect Monster",
"desc": "FLIP: Destroys all of your opponent's face-up \"Swords of Revealing Light\" on the field. If \"Swords of Revealing Light\" is destroyed, you can perform your Battle Phase twice this turn (or your next turn, if activated during your opponent's turn).",
"atk": 950,
"def": 1500,
"level": 4,
"race": "Aqua",
"attribute": "WATER",
"banlist_info": {
"ban_tcg": "Banned",
"ban_ocg": "Limited"
},
"card_images": [
{
"id": 72053645,
"image_url": "https://storage.googleapis.com/ygoprodeck.com/pics/72053645.jpg",
"image_url_small": "https://storage.googleapis.com/ygoprodeck.com/pics_small/72053645.jpg"
}
]
},
{
"id": 81122844,
"name": "Wind-Up Carrier Zenmaity",
"type": "XYZ Monster",
"desc": "2 Level 3 monsters\nOnce per turn: You can detach 1 Xyz Material from this card; Special Summon 1 \"Wind-Up\" monster from your hand or Deck. When a face-up \"Wind-Up\" monster on the field is destroyed and sent to your Graveyard (except during the Damage Step): You can detach 1 Xyz Material from this card to target that monster; return that target to the hand.",
"atk": 1500,
"def": 1500,
"level": 3,
"race": "Machine",
"attribute": "WATER",
"archetype": "Wind-Up",
"banlist_info": {
"ban_tcg": "Banned",
"ban_ocg": "Limited"
},
"card_images": [
{
"id": 81122844,
"image_url": "https://storage.googleapis.com/ygoprodeck.com/pics/81122844.jpg",
"image_url_small": "https://storage.googleapis.com/ygoprodeck.com/pics_small/81122844.jpg"
}
]
}
]
};
但是每当我尝试运行我的代码时,它总是会出现这个错误:
Failed to compile.
./src/services/testbanlist.js
SyntaxError: Missing semicolon. (2:10)
1 | {
> 2 | "data": [
| ^
3 | {
4 | "id": 72053645,
5 | "name": "Weather Report",
有没有人看到我的代码中的错误在哪里?VSCode 没有准确显示分号的位置。
解决方案
文件的扩展名应为 .json。testbanlist.json 不是 testbanlist.js
推荐阅读
- c# - 如何在 .NET Core 3 的 Controller 的构造函数中访问 HttpContext?
- angular - 获取Angular中更改事件的选定选项值
- ml.net - ML.Net:具有多个输出的 ONNX 模型 - 推理时间差
- build - VS2019中build和Clean&Rebuild有什么区别
- python - 在日志中写入python脚本的内容
- mysql - 选择日期最长的消息
- r - 并行调用 Rcpp::Function
- sql - 在 oracle 中将旧式联接转换为 ansi 联接
- javascript - 我在引导表上制作手风琴,数据来自 ng-repeat 循环,没有 ui.bootstrap 也没有 jquery
- xamarin - 安装 Plugin.FirebasePushNotification 后无法将构建操作设置为 GoogleServiceJson