Home > Mobile >  json.loads() (JSONDecodeError: Expecting value: line 1 column 1 (char 0))
json.loads() (JSONDecodeError: Expecting value: line 1 column 1 (char 0))

Time:04-28

I am trying to use json.load() but it is not working.

url = "http://api.worldbank.org/v2/country/all/indicator/"   ";".join(indicators)   
source   date_range   per_page
response = requests.get(url)
print(response)
result = response.content
result = json.loads(result)
result

But I get this error any ideas? error message

CodePudding user response:

globalbank api defaults to XML, you need to tell it which format you need. try it like this:

url = "http://api.worldbank.org/v2/country/all/indicator/"   ";".join(indicators)   source   date_range   per_page   '&format=json'
  • Related