How to request and process JSON using python?

I am trying to send a GET request to a url that I know returns data in JSON form using python.

I would like to know how to send this request to http://someurl/path/to/json , and how to parse it - preferably on a python dict.

+68
json python
May 12 '10 at 9:28
source share
2 answers

For any requests with urls you can check requests . For JSON in particular:

 >>> import requests >>> r = requests.get('https://github.com/timeline.json') >>> r.json() [{u'repository': {u'open_issues': 0, u'url': 'https://github.com/... 
+94
Sep 13 '12 at 8:22
source share

The Python standard library has json and urllib2 .

 import json import urllib2 data = json.load(urllib2.urlopen('http://someurl/path/to/json')) 
+67
May 12 '10 at 9:35
source share



All Articles