Skip to content

Instantly share code, notes, and snippets.

@hondajojo
Created July 30, 2015 11:45
Show Gist options
  • Save hondajojo/59da8e65bd079ac6db8c to your computer and use it in GitHub Desktop.
Save hondajojo/59da8e65bd079ac6db8c to your computer and use it in GitHub Desktop.
json to python object
#!/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