Reputation: 79
I am trying to parse json obtained from this api call: https://poloniex.com/public?command=returnTicker
But when I run the commands:
print site_name
site = urllib2.Request(site_name)
response=urllib2.urlopen(site_name)
print response.read()
t= json.loads(response.read())
I get:
https://poloniex.com/public?command=returnTicker
{"BTC_BCN": ... (rest of json response)
ValueError: No JSON object could be decoded
I have validated the resulting json object using www.jsonlint.com and it is valid. What am I doing wrong?
Upvotes: 0
Views: 216
Reputation: 140178
if you print response.read()
, then the next time you try to read
from it you'll get an empty string.
Empty string is not a valid json
string.
Upvotes: 3