Skip to content

feat: handling timedelta objects in the FriendlyEncoder class#16

Merged
RobertoPrevato merged 1 commit intoNeoteroi:mainfrom
arthurbrenno:main
Apr 1, 2025
Merged

feat: handling timedelta objects in the FriendlyEncoder class#16
RobertoPrevato merged 1 commit intoNeoteroi:mainfrom
arthurbrenno:main

Conversation

@arthurbrenno
Copy link
Contributor

I came to an use case in Blacksheep where I needed to return timedelta objects. This timedelta object was inside a Pydantic BaseModel. But I got the error TypeError: Object of type timedelta is not JSON serializable because essentials didn't handle timedelta objects. Leaving this small contrib. Hope it helps others too.

Changes:

  • Added another if statement, that checkes if obj is an instance of a timedelta object.

@RobertoPrevato RobertoPrevato merged commit 84e4e13 into Neoteroi:main Apr 1, 2025
1 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants