python json string conversion

JSON parsing examples

功能:把json字符串转成python语言的dict

#coding: utf-8
import json

json_str = """
{
    "id" : 90,
    "name" : "python",
    "url" : "http://www.baidu.com",
    "title" : "Python",
    "title_alternative" : "Python",
    "topics" : 7646,
    "stars" : 4862,
        "header" : "Python 语言",
        "footer" : null,
    "created" : 1278683336,
    "avatar_mini" : "//v2ex.assets.uxengine.net/90_mini.png?m=1504",
}
"""
res = json.loads(json_str)

print(res['id']) # 90
print(res['name']) # python
print(res['url']) # http://www.baidu.com

Guess you like

Origin www.cnblogs.com/niuniumother/p/11284233.html