【发布时间】:2018-12-13 21:14:48
【问题描述】:
以下是有效的 JSON 吗:
"AGENT ": {
"pending": [],
"active": null,
"completed": [{}]
},
"MONITORING": {
"pending": [],
"active": null,
"completed": [{}]
}
json 验证器站点 (https://jsonlint.com/) 说它不是。我怎样才能使它成为一个有效的 json ?将其转换为 python 中的 dict 会截断 json 块(“代理”部分)。如何在不丢失 json 块的情况下将此块转换为 python 中的字典?这是从 GET 请求返回的 JSON。使用以下不起作用
response = requests.get(<url>)
data = response.content
json_data = json.dumps(data)
item_dict = json.loads(data)
item_dict = data
【问题讨论】: