Skip to content

Can't serialize ObjectId聽#107

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions