2017-03-11 98 views
-1

這是我第一次使用json文件。我有一個JSON文件Python JSONDecodeError:期望','分隔符

{ 
"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" : "" 
     } 
]} 

現在我想獲得的數據形成使用

with open('schema-map.json') as json_data: 
d = json.load(json_data) 
print(d) 

我收到以下錯誤此JSON。 JSONDecodeError: Expecting ',' delimiter 我想知道如果json文件有什麼問題,或者代碼可以修改。

+1

在最後一個']之前缺少一個大括號。 – Psidom

回答

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" : "" 
     } 
    } 
]}