diff --git a/aiohttp/web_reqrep.py b/aiohttp/web_reqrep.py index 3eb3f8a8ffe..6995df15eb8 100644 --- a/aiohttp/web_reqrep.py +++ b/aiohttp/web_reqrep.py @@ -326,8 +326,13 @@ def text(self): return bytes_body.decode(encoding) @asyncio.coroutine - def json(self, *, loads=json.loads): + def json(self, *, loads=json.loads, loader=None): """Return BODY as JSON.""" + if loader: + warnings.warn( + 'Using `loader` is deprecated, use `loads` instead', + DeprecationWarning) + loads = loader body = yield from self.text() return loads(body) diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py index c7d2c231d90..cd5b03077f9 100644 --- a/tests/test_web_functional.py +++ b/tests/test_web_functional.py @@ -144,6 +144,8 @@ def handler(request): self.assertEqual(dct, data) data2 = yield from request.json(loads=json.loads) self.assertEqual(data, data2) + data3 = yield from request.json(loader=json.loads) + self.assertEqual(data, data3) resp = web.Response() resp.content_type = 'application/json' resp.body = json.dumps(data).encode('utf8')