Fix: TypeError: Object of type 'Decimal' is not JSON serializable in Python 3.6
Use a override default
:
import json
from decimal import Decimal
def default(obj):
if isinstance(obj, Decimal):
return str(obj)
raise TypeError("Object of type '%s' is not JSON serializable" % type(obj).__name__)
json.dumps(testlist, default=default)
ref: https://stackoverflow.com/questions/31202956/json-typeerror-decimal34-3-is-not-json-serializable