Skip to content
Myr

Merge pull request #1132 from sburns/jsonkwargs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Pass kwargs to json.loads

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 0c09d16, 2bcc4a7 · Browse files · 1 file+7 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−4 removed

  • other:+7 added−4 removed

1 file+7 added−4 removed

modified:requests/models.py+7 added-4 removed
594 unmodified lines
595 content = str(self.content, errors='replace')596597 return content598599 def json(self):600 """Returns the json-encoded content of a response, if any."""599 def json(self, **kwargs):600 """Returns the json-encoded content of a response, if any.601602 :param \*\*kwargs: Optional arguments that ``json.loads`` takes.603 """604605 if not self.encoding and len(self.content) > 3:606 # No encoding set. JSON RFC 4627 section 3 states we should expect607 # UTF-8, -16 or -32. Detect which one to use; If the detection or608 # decoding fails, fall back to `self.text` (using chardet to make609 # a best guess).610 encoding = guess_json_utf(self.content)611 if encoding is not None:609 return json.loads(self.content.decode(encoding))610 return json.loads(self.text or self.content)612 return json.loads(self.content.decode(encoding), **kwargs)613 return json.loads(self.text or self.content, **kwargs)614615 @property616 def links(self):617 """Returns the parsed header links of the response, if any."""
33 unmodified lines