这是我第一次使用json文件。我有一个json文件
{
"schema-map" : [
{
"src-file": "employee_master.xlsx",
"dest-file": "employee_master.xlsx",
"field-map" : {
"user_id" : "Unique ID",
"employee_name" : "Name",
"employee_address" : "Address for Communication",
"pin_code" : "",
"employee_code" : "Codes",
"bank_account_no" : "bank_account_no",
"telephone" : "",
"email_id" : "email_id",
"pan" : "PAN Card Num",
"dependent_family_member" : ""
}
]}
现在我正在尝试使用
从json获取数据with open('schema-map.json') as json_data:
d = json.load(json_data)
print(d)
我收到以下错误。JSONDecodeError: Expecting ',' delimiter
我想知道如果json文件有什么问题,或者代码可以修改。
答案 0 :(得分:2)
您的JSON文件缺少结束}
括号以关闭field-map
组。
{
"schema-map" : [
{
"src-file": "employee_master.xlsx",
"dest-file": "employee_master.xlsx",
"field-map" : {
"user_id" : "Unique ID",
"employee_name" : "Name",
"employee_address" : "Address for Communication",
"pin_code" : "",
"employee_code" : "Codes",
"bank_account_no" : "bank_account_no",
"telephone" : "",
"email_id" : "email_id",
"pan" : "PAN Card Num",
"dependent_family_member" : ""
}
}
]}