Fix #2799: Update Quickstart documentation of Response.json()

This commit is contained in:
Hosam Aly
2015-10-02 23:58:48 +01:00
parent 3c6f89b8f4
commit 443d07e0d3
+8 -2
View File
@@ -145,8 +145,14 @@ There's also a builtin JSON decoder, in case you're dealing with JSON data::
[{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...
In case the JSON decoding fails, ``r.json`` raises an exception. For example, if
the response gets a 401 (Unauthorized), attempting ``r.json`` raises ``ValueError:
No JSON object could be decoded``
the response gets a 204 (No Content), or if the response contains invalid JSON,
attempting ``r.json`` raises ``ValueError: No JSON object could be decoded``.
It should be noted that the success of the call to ``r.json`` does **not**
indicate the success of the response. Some servers may return a JSON object in a
failed response (e.g. error details with HTTP 500). Such JSON will be decoded
and returned. To check that a request is successful, use ``r.ok == True`` or
``r.raise_for_status()``.
Raw Response Content