Skip to content

Can't serialize ObjectId #107

@Saluev

Description

@Saluev

Funny thing: I seem unable to serialize document containing ObjectId generated by this very same library 🤔

>>> bson.dumps({"_id": bson.ObjectId()})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/bson/__init__.py", line 39, in dumps
    return encode_document(obj, [],
  File "/usr/local/lib/python3.9/site-packages/bson/codec.py", line 238, in encode_document
    encode_value(name, value, buf, traversal_stack,
  File "/usr/local/lib/python3.9/site-packages/bson/codec.py", line 226, in encode_value
    raise UnknownSerializerError(name, value)
bson.codec.UnknownSerializerError: Unable to serialize: key '_id' value: 60c11e2272af374b05e46919 type: <class 'bson.objectid.ObjectId'>

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions