MCPcopy
hub / github.com/urllib3/urllib3 / json

Method json

src/urllib3/response.py:517–536  ·  view source on GitHub ↗

Deserializes the body of the HTTP response as a Python object. The body of the HTTP response must be encoded using UTF-8, as per `RFC 8529 Section 8.1 <https://www.rfc-editor.org/rfc/rfc8259#section-8.1>`_. To use a custom JSON decoder pass the result of :attr:`HTT

(self)

Source from the content-addressed store, hash-verified

515 raise NotImplementedError()
516
517 def json(self) -> typing.Any:
518 """
519 Deserializes the body of the HTTP response as a Python object.
520
521 The body of the HTTP response must be encoded using UTF-8, as per
522 `RFC 8529 Section 8.1 <https://www.rfc-editor.org/rfc/rfc8259#section-8.1>`_.
523
524 To use a custom JSON decoder pass the result of :attr:`HTTPResponse.data` to
525 your custom decoder instead.
526
527 If the body of the HTTP response is not decodable to UTF-8, a
528 `UnicodeDecodeError` will be raised. If the body of the HTTP response is not a
529 valid JSON document, a `json.JSONDecodeError` will be raised.
530
531 Read more :ref:`here <json_content>`.
532
533 :returns: The body of the HTTP response as a Python object.
534 """
535 data = self.data.decode("utf-8")
536 return _json.loads(data)
537
538 @property
539 def url(self) -> str | None:

Calls

no outgoing calls