【发布时间】:2021-05-11 09:43:52
【问题描述】:
当我尝试在 python 中加载以下 json 时:
"foo": {
"foo_id": "1",
"foo_name": "i",
"foo_client_id": "2",
"foo_client": "b",
}
我收到以下错误:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
如何将其解析为合法的 json?
【问题讨论】:
-
1) 将
foo包裹在另一个对象 ({}) 中。 2) 去掉b之后的逗号。 -
你所拥有的不是有效的 JSON 格式——它不允许在最后一项的末尾使用逗号(与 Python 不同)。