MCPcopy
hub / github.com/aio-libs/aiohttp / json

Method json

aiohttp/client_reqrep.py:745–762  ·  view source on GitHub ↗

Read and decodes JSON response.

(self, *, encoding=None, loads=json.loads)

Source from the content-addressed store, hash-verified

743
744 @asyncio.coroutine
745 def json(self, *, encoding=None, loads=json.loads):
746 """Read and decodes JSON response."""
747 if self._content is None:
748 yield from self.read()
749
750 ctype = self.headers.get(hdrs.CONTENT_TYPE, '').lower()
751 if 'json' not in ctype:
752 client_logger.warning(
753 'Attempt to decode JSON with unexpected mimetype: %s', ctype)
754
755 stripped = self._content.strip()
756 if not stripped:
757 return None
758
759 if encoding is None:
760 encoding = self._get_encoding()
761
762 return loads(stripped.decode(encoding))
763
764 if PY_35:
765 @asyncio.coroutine

Callers 1

readMethod · 0.95

Calls 4

readMethod · 0.95
_get_encodingMethod · 0.95
decodeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected