Skip to content

Commit 0492061

Browse files
indoor47patchback[bot]
authored andcommitted
docs: replace deprecated ujson with orjson in client quickstart (#12152)
(cherry picked from commit c1981ef)
1 parent 3c7f1d6 commit 0492061

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CHANGES/10795.doc.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Replaced the deprecated ``ujson`` library with ``orjson`` in the
2+
client quickstart documentation. ``ujson`` has been put into
3+
maintenance-only mode; ``orjson`` is the recommended alternative.
4+
-- by :user:`indoor47`

docs/client_quickstart.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,22 @@ Any of session's request methods like :func:`request`,
203203

204204

205205
By default session uses python's standard :mod:`json` module for
206-
serialization. But it is possible to use different
207-
``serializer``. :class:`ClientSession` accepts ``json_serialize``
208-
parameter::
206+
serialization. But it is possible to use a different
207+
``serializer``. :class:`ClientSession` accepts ``json_serialize`` and
208+
``json_serialize_bytes`` parameters::
209209

210-
import ujson
210+
import orjson
211211

212212
async with aiohttp.ClientSession(
213-
json_serialize=ujson.dumps) as session:
213+
json_serialize_bytes=orjson.dumps) as session:
214214
await session.post(url, json={'test': 'object'})
215215

216216
.. note::
217217

218-
``ujson`` library is faster than standard :mod:`json` but slightly
219-
incompatible.
218+
``orjson`` library is faster than standard :mod:`json` and is actively
219+
maintained. Since ``orjson.dumps`` returns :class:`bytes`, pass it via
220+
the ``json_serialize_bytes`` parameter to avoid unnecessary
221+
encoding/decoding overhead.
220222

221223
JSON Response Content
222224
=====================

docs/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ pytest
266266
Pytest
267267
qop
268268
Quickstart
269+
quickstart
269270
quote’s
270271
rc
271272
readonly

0 commit comments

Comments
 (0)