美文网首页
python解析JSON异常 - Expecting 'STRI

python解析JSON异常 - Expecting 'STRI

作者: JoeSense | 来源:发表于2017-09-20 14:58 被阅读0次

原因:JSON中的key未加双引号.导致解析错误.例如下面的格式.

{
    result: [
        {
            comment: "酷表情",
            createTime: "2016-08-11 16:12:25.0",
            title: "",
            updateTime: "2016-08-13 14:56:45.0"
        },
        
    ]
}

使用python的三方JSON库 demjson 来解析即可.

import demjson

jsondata = demjson.decode_file('file_path')
print json.dumps(jsondata, encoding="UTF-8", ensure_ascii=False)

相关文章

网友评论

      本文标题:python解析JSON异常 - Expecting 'STRI

      本文链接:https://www.haomeiwen.com/subject/pnlosxtx.html