为什么这个 json 文件会导致 'expecting value' 错误?
Why does this json file cause an 'expecting value' error?
我正在尝试将文件加载为 JSON。
这是数据文件:
{"Title":"Assignment Checker",
"Q1_Solution":10517,
"Q2_Solution":12,
"Q3_Solution":52,
"Q4_Solution":84,
"Q5_Solution":50,
"Q6_Solution":1971,
"Q7_Solution":("Hip", "Flat", "Gambrel", "Mansard", "Shed", "Gable")}
这是失败的代码:
f = open("checkerData.json")
checkerData = json.load(f)
f.close()
我收到这个错误:
JSONDecodeError: Expecting value: line 8 column 16 (char 166)
括号在 JSON 中无效,无法表示列表(数组)。
修复 JSON 以使用 [
和 ]
。
这是有效的:
{
"Title": "Assignment Checker",
"Q1_Solution": 10517,
"Q2_Solution": 12,
"Q3_Solution": 52,
"Q4_Solution": 84,
"Q5_Solution": 50,
"Q6_Solution": 1971,
"Q7_Solution": [
"Hip",
"Flat",
"Gambrel",
"Mansard",
"Shed",
"Gable"
]
}
我正在尝试将文件加载为 JSON。
这是数据文件:
{"Title":"Assignment Checker",
"Q1_Solution":10517,
"Q2_Solution":12,
"Q3_Solution":52,
"Q4_Solution":84,
"Q5_Solution":50,
"Q6_Solution":1971,
"Q7_Solution":("Hip", "Flat", "Gambrel", "Mansard", "Shed", "Gable")}
这是失败的代码:
f = open("checkerData.json")
checkerData = json.load(f)
f.close()
我收到这个错误:
JSONDecodeError: Expecting value: line 8 column 16 (char 166)
括号在 JSON 中无效,无法表示列表(数组)。
修复 JSON 以使用 [
和 ]
。
这是有效的:
{
"Title": "Assignment Checker",
"Q1_Solution": 10517,
"Q2_Solution": 12,
"Q3_Solution": 52,
"Q4_Solution": 84,
"Q5_Solution": 50,
"Q6_Solution": 1971,
"Q7_Solution": [
"Hip",
"Flat",
"Gambrel",
"Mansard",
"Shed",
"Gable"
]
}