import datetime as dt import decimal def alchemyencoder(obj): """JSON encoder function with support for ISO 8601 datetime serialization and Decimal to float casting""" if isinstance(obj, dt.datetime): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return float(obj)