bson – BSON (Binary JSON) Encoding and Decoding¶
BSON (Binary JSON) encoding and decoding.
The mapping from Python types to BSON types is as follows:
Python Type |
BSON Type |
Supported Direction |
|---|---|---|
None |
null |
both |
bool |
boolean |
both |
int [1] |
int32 / int64 |
py -> bson |
int64 |
both |
|
float |
number (real) |
both |
str |
string |
both |
list |
array |
both |
dict |
object |
both |
object |
both |
|
object |
py -> bson |
|
object |
both [2] |
|
UTC datetime |
both |
|
UTC datetime |
both [5] |
|
regex |
both |
|
compiled re [7] |
regex |
py -> bson |
binary |
both |
|
binary |
both |
|
oid |
both |
|
dbref |
both |
|
dbpointer |
bson -> py |
|
None |
undefined |
bson -> py |
code |
both |
|
str |
symbol |
bson -> py |