diff --git a/CHANGES/10795.doc.rst b/CHANGES/10795.doc.rst new file mode 100644 index 00000000000..91094f70c13 --- /dev/null +++ b/CHANGES/10795.doc.rst @@ -0,0 +1,4 @@ +Replaced the deprecated ``ujson`` library with ``orjson`` in the +client quickstart documentation. ``ujson`` has been put into +maintenance-only mode; ``orjson`` is the recommended alternative. +-- by :user:`indoor47` diff --git a/docs/client_quickstart.rst b/docs/client_quickstart.rst index fc6d3875ea1..1ab5610b824 100644 --- a/docs/client_quickstart.rst +++ b/docs/client_quickstart.rst @@ -206,20 +206,22 @@ Any of session's request methods like :func:`request`, By default session uses python's standard :mod:`json` module for -serialization. But it is possible to use different -``serializer``. :class:`ClientSession` accepts ``json_serialize`` -parameter:: +serialization. But it is possible to use a different +``serializer``. :class:`ClientSession` accepts ``json_serialize`` and +``json_serialize_bytes`` parameters:: - import ujson + import orjson async with aiohttp.ClientSession( - json_serialize=ujson.dumps) as session: + json_serialize_bytes=orjson.dumps) as session: await session.post(url, json={'test': 'object'}) .. note:: - ``ujson`` library is faster than standard :mod:`json` but slightly - incompatible. + ``orjson`` library is faster than standard :mod:`json` and is actively + maintained. Since ``orjson.dumps`` returns :class:`bytes`, pass it via + the ``json_serialize_bytes`` parameter to avoid unnecessary + encoding/decoding overhead. JSON Response Content ===================== diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 9890b228e01..365e99c3747 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -266,6 +266,7 @@ pytest Pytest qop Quickstart +quickstart quote’s rc readline