Created
July 30, 2015 11:45
-
-
Save hondajojo/59da8e65bd079ac6db8c to your computer and use it in GitHub Desktop.
json to python object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# json to python object | |
# refer to https://gist.github.com/clowwindy/1699170 | |
import json | |
import requests | |
class storge(object): | |
def __init__(self,dct): | |
self.__dict__ = dct | |
res = requests.get('http://www.v2ex.com/api/members/show.json?username=Livid',verify=False).content | |
result = json.loads(res,object_hook=storge) | |
print result.status | |
print result.id | |
#print result['status'] #this is old way |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment