Skip to content

Instantly share code, notes, and snippets.

@Gunio
Created October 18, 2011 05:25
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Gunio/1294675 to your computer and use it in GitHub Desktop.
Save Gunio/1294675 to your computer and use it in GitHub Desktop.
Parsing JSON in python
import requests
import simplejson
r = requests.get('https://github.com/timeline.json')
c = r.content
j = simplejson.loads(c)
for item in j:
print item['repository']['name']
@psachin
Copy link

psachin commented Nov 24, 2013

How can I parse a value of "raw_url" and "content"? in https://api.github.com/gists/6386902

@nmcv
Copy link

nmcv commented Apr 1, 2014

@harishvc
Copy link

harishvc commented Oct 11, 2016

Code could be further simplified using r.json(). Below is an example to parse @harishvc Github public timeline.

import requests
import simplejson

#python 3.x
r = requests.get('Https://api.github.com/users/harishvc/events/public')
for item in r.json():
    for c in item['payload']['commits']:
        print(c['sha'], c['message'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment