import datetime as dt import decimal def alchemyencoder(obj): """JSON encoder function for SQLAlchemy special classes.""" if isinstance(obj, dt.datetime): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return float(obj)