Skip to content

Conversation

kindofluke
Copy link

@kindofluke kindofluke commented Mar 25, 2025

Why: There are a lot of advantages to returning a slightly richer python object as opposed to simply a dictionary or string. Say perhaps, you are returning objects that will be tracked by an ORM or you are returning simple data classes.

What: Leverages a simple enhanced JSON encoder class that handles dataclasses, datetimes, and an __html__ method. This is copy of the implementation for flask https://github.com/pallets/flask/blob/f61172b8dd3f962d33f25c50b2f5405e90ceffa5/src/flask/json/provider.py#L108

How: Adds a DefaultJSONEncoder to the tools orchestration that is passed into json.dumps. This also enables users to override the default if needed.

I have run pre-commit and I have run most of the test suite but a small subset of the provider tests I am not able to run.

Thanks really great library that I use a lot.

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.

1 participant