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
11 lines
311 B
Python
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)
|