如何解析json

json片段:

{

    "code": 1,

    "msg": "\u8bf7\u6c42\u6210\u529f",

    "data": {

        "list": [{

            "xj_id": 160,

            "applyid": 1590220612,

            "xj_time": "2018-12-07 15:38:26",

            "status": 4,

            "insurance_years": 3,

            "applicant": "\u51ef\u67ab\u878d\u8d44\u79df\u8d41\u6709\u9650\u516c\u53f8",

            "guard_time": "2018-12-07",

            "op_time": "2018-12-07 15:39:35"

        }]

    }

}

import  jsonpath

import  json

dic=json.loads("json字符串")

li=jsonpath.jsonpath(字典,"$.code")   

$代表根目录     .代表下一级

注意:返回值类型是list,如果取不到值返回False

猜你喜欢

转载自blog.csdn.net/qq_39676248/article/details/89083589