absent1706 / sqlalchemy-mixins

Active Record, Django-like queries, nested eager load and beauty __repr__ for SQLAlchemy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: SerializeMixin - Add `to_json()` with support for custom JSON encoding

lararosekelley opened this issue · comments

Types like UUID or custom types from libraries like sqlalchemy-utils cannot be serialized to JSON by default from a Python dict, making monkey-patching the default JSONEncoder or providing a custom encoder class common practice. It would be nice to add a to_json() method to the SerializeMixin alongside the provided to_dict() method, with the ability to pass in an encoder param to the function to serialize a model to JSON.

@michaelbukachi I would like to work on this issue, the thing is idk how to do this, if anyone can give me a broad overview of how to implement something like this, that would be nice