Comment

Peter Bengtsson

It depends on if you have `simplejson` installed or not. If you look at `site-packages/requests/compat.py` you'll see that it does this:

try:
    import simplejson as json
except ImportError:
    import json

Basically, if `simplejson` is installed in the environment, requests uses that instead.

You need to be aware of that when you are aware of `response.json()` potentially failing.

I think I need to write an update about that.

Parent comment

Jack M

The exception is wrong in this guide. requests uses simplejson not json, so the exception will not be caught. .local/lib/python3.6/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads return _default_decoder.decode(s) File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)