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

bson.int64.Int64

int64

both

float

number (real)

both

str

string

both

list

array

both

dict

object

both

SON

object

both

Mapping

object

py -> bson

RawBSONDocument

object

both [2]

datetime.datetime [3] [4]

UTC datetime

both

DatetimeMS

UTC datetime

both [5]

Regex

regex

both

compiled re [7]

regex

py -> bson

Binary

binary

both

uuid.UUID [6]

binary

both

ObjectId

oid

both

DBRef

dbref

both

DBRef

dbpointer

bson -> py

None

undefined

bson -> py

Code

code

both

str

symbol

bson -> py