Skip to content

Commit 0abcb7a

Browse files
committed
Advertise python-bsonjs in json_util and FAQ documentation
1 parent c58f5e4 commit 0abcb7a

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

bson/json_util.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
instances (as they are extended strings you can't provide custom defaults),
4848
but it will be faster as there is less recursion.
4949
50+
.. note::
51+
If your application does not need the flexibility offered by
52+
:class:`JSONOptions` and spends a large amount of time in the `json_util`
53+
module, look to
54+
`python-bsonjs <https://github.com/mongodb-labs/python-bsonjs>`_ for a nice
55+
performance improvement. `python-bsonjs` is a fast BSON to MongoDB
56+
Extended JSON converter for Python built on top of
57+
`libbson <https://github.com/mongodb/libbson>`_. `python-bsonjs` works best
58+
with PyMongo when using :class:`~bson.raw_bson.RawBSONDocument`.
59+
5060
.. versionchanged:: 2.8
5161
The output format for :class:`~bson.timestamp.Timestamp` has changed from
5262
'{"t": <int>, "i": <int>}' to '{"$timestamp": {"t": <int>, "i": <int>}}'.

doc/faq.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,19 @@ Yes. See the configuration guide for :ref:`pymongo-and-mod_wsgi`.
435435

436436
How can I use something like Python's :mod:`json` module to encode my documents to JSON?
437437
----------------------------------------------------------------------------------------
438-
The :mod:`json` module won't work out of the box with all documents
439-
from PyMongo as PyMongo supports some special types (like
440-
:class:`~bson.objectid.ObjectId` and :class:`~bson.dbref.DBRef`)
441-
that are not supported in JSON. We've added some utilities for working
442-
with JSON in the :mod:`~bson.json_util` module.
438+
:mod:`~bson.json_util` is PyMongo's built in, flexible tool for using
439+
Python's :mod:`json` module with BSON documents and `MongoDB Extended JSON
440+
<https://docs.mongodb.com/manual/reference/mongodb-extended-json/>`_. The
441+
:mod:`json` module won't work out of the box with all documents from PyMongo
442+
as PyMongo supports some special types (like :class:`~bson.objectid.ObjectId`
443+
and :class:`~bson.dbref.DBRef`) that are not supported in JSON.
444+
445+
`python-bsonjs <https://github.com/mongodb-labs/python-bsonjs>`_ is a fast
446+
BSON to MongoDB Extended JSON converter built on top of
447+
`libbson <https://github.com/mongodb/libbson>`_. `python-bsonjs` does not
448+
depend on PyMongo and can offer a nice performance improvement over
449+
:mod:`~bson.json_util`. `python-bsonjs` works best with PyMongo when using
450+
:class:`~bson.raw_bson.RawBSONDocument`.
443451

444452
Why do I get OverflowError decoding dates stored by another language's driver?
445453
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)