MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / decode

Method decode

bson/__init__.py:1436–1468  ·  view source on GitHub ↗

Decode this BSON data. By default, returns a BSON document represented as a Python :class:`dict`. To use a different :class:`MutableMapping` class, configure a :class:`~bson.codec_options.CodecOptions`:: >>> import collections # From Python standard library.

(  # type:ignore[override]
        self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS
    )

Source from the content-addressed store, hash-verified

1434 return cls(encode(document, check_keys, codec_options))
1435
1436 def decode( # type:ignore[override]
1437 self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS
1438 ) -> dict[str, Any]:
1439 """Decode this BSON data.
1440
1441 By default, returns a BSON document represented as a Python
1442 :class:`dict`. To use a different :class:`MutableMapping` class,
1443 configure a :class:`~bson.codec_options.CodecOptions`::
1444
1445 >>> import collections # From Python standard library.
1446 >>> import bson
1447 >>> from bson.codec_options import CodecOptions
1448 >>> data = bson.BSON.encode({'a': 1})
1449 >>> decoded_doc = bson.BSON(data).decode()
1450 <type 'dict'>
1451 >>> options = CodecOptions(document_class=collections.OrderedDict)
1452 >>> decoded_doc = bson.BSON(data).decode(codec_options=options)
1453 >>> type(decoded_doc)
1454 <class 'collections.OrderedDict'>
1455
1456 :param codec_options: An instance of
1457 :class:`~bson.codec_options.CodecOptions`.
1458
1459 .. versionchanged:: 3.0
1460 Removed `compile_re` option: PyMongo now always represents BSON
1461 regular expressions as :class:`~bson.regex.Regex` objects. Use
1462 :meth:`~bson.regex.Regex.try_compile` to attempt to convert from a
1463 BSON regular expression to a Python regular expression object.
1464
1465 Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with
1466 `codec_options`.
1467 """
1468 return decode(self, codec_options)
1469
1470
1471def has_c() -> bool:

Calls 1

decodeFunction · 0.85