mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
refactor(backend): add json_encoders to BaseModel configuration (dev-3.x)
This commit introduces a custom JSON encoder for the Default type within the BaseModel configuration of the aiogram package. By specifying how the Default type is serialized, this change ensures consistent representation of Default instances in JSON output, enhancing the predictability of the serialization process.
This commit is contained in:
parent
acf52f468c
commit
7653895dd2
1 changed files with 3 additions and 0 deletions
|
|
@ -16,6 +16,9 @@ class TelegramObject(BotContextController, BaseModel):
|
|||
populate_by_name=True,
|
||||
arbitrary_types_allowed=True,
|
||||
defer_build=True,
|
||||
json_encoders={
|
||||
Default: lambda obj: obj.name,
|
||||
}
|
||||
)
|
||||
|
||||
@model_validator(mode="before")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue