I am having difficulty parsing a json string that appears to be valid json.
My code is the following. I'm trying to grab some simple json from a URL.
import urllib2
import simplejson
req = urllib2.Request("http://www.rentrent.org/RENT/Ads.aspx?xmin=-118.01925659179687&ymin=33.71948521132481&xmax=-117.68142700195314&ymax=33.85644642218431&bd=&ba=&pets=-1&type=2&throwErrorIfOverLimit=false&callback=xxx")
opener = urllib2.build_opener()
f = opener.open(req)
content = f.read();
print "content = " + content # Appears to print valid json string
json = simplejson.loads(content)
I get an error on simplejson.loads(content)
:
raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
This is confusing because content
appears to be a perfectly good json string.
I need to get to this data as individual elements. Any ideas how to get rid of this error?