json.decoder.JSONDecodeError:期望值:,json.decoder.JSONDecodeError:期望属性名称用双引号引起来:

json.decoder.JSONDecodeError:期望值:,json.decoder.JSONDecodeError:期望属性名称用双引号引起来:

问题描述:

我正在使用Python在我的文件中使用JSON:

Hi I am working with JSON in my file in Python:

import json
userData = '''[
{
    "userID" : "20",
    "devices" : {
        "360020000147343433313337" : "V33_03",
        "3f0026001747343438323536" : "Door_03",
        "170035001247343438323536" : "IR_06",
        "28004c000651353530373132" : "BED_17"
    }
},

]'''

info = json.loads(userData)

加载时出现此错误: json.decoder.JSONDecodeError:预期值:

I get this error when I load it: json.decoder.JSONDecodeError: Expecting value:

,或者有时当我添加一些内容时: json.decoder.JSONDecodeError:期望属性名称用双引号引起来:

or sometimes when I add something: json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes:

尝试使用ast模块

例如:

import ast
userData = '''[
{
    "userID" : "20",
    "devices" : {
        "360020000147343433313337" : "V33_03",
        "3f0026001747343438323536" : "Door_03",
        "170035001247343438323536" : "IR_06",
        "28004c000651353530373132" : "BED_17"
    }
},
]'''

info = ast.literal_eval(userData)
print(info)