diff --git a/pydantic_extra_types/mongo_object_id.py b/pydantic_extra_types/mongo_object_id.py index 14336f9..767f7b5 100644 --- a/pydantic_extra_types/mongo_object_id.py +++ b/pydantic_extra_types/mongo_object_id.py @@ -57,7 +57,7 @@ def __get_pydantic_core_schema__(cls, _: Any, __: GetCoreSchemaHandler) -> core_ ), ] ), - serialization=core_schema.plain_serializer_function_ser_schema(lambda x: str(x)), + serialization=core_schema.plain_serializer_function_ser_schema(lambda x: str(x), when_used='json'), ) @classmethod