You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
311 B
Python

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