2 回答

TA贡献1995条经验 获得超2个赞
您收到错误,因为您的文件格式不正确,因此调用将引发.jsonjson.load()JSONDecodeError
您的结构应如下所示:json
{
"companies": {
"company1": [
{
"path": "C:/USER/Path/Company1/",
"files": [
{
"_CO": {
"ID": "ID",
"Report Number": "Report_Number"
}
},
{
"_TR": {
"ID": "Trade_Ident",
"Report Number": "Number of Report"
}
}
]
}
],
"company2": [
{
"path": "C:/USER/Path/Company2/",
"files": [
{
"_CO": {
"ID": "Identification",
"Report Number": "Report-Number"
}
},
{
"_TR": {
"ID": "Ident",
"Report Number": "NumberReport"
}
}
]
}
]
}
}
希望它能帮助你!

TA贡献1852条经验 获得超1个赞
您有一些对象(带有大括号的对象)没有键,例如在
{
{"_CO": {"ID": "ID", "Report Number": "Report_Number"}}, ...
JSON 中的对象是键值对。只需取下外部一组大括号,它应该没问题。
您可以使用一些在线JSON格式化程序/验证程序,就像这样,它很容易指出问题。否则,您可以为编辑器使用一些 JSON linter。它只是为您完成工作,并改善缩进:)
添加回答
举报