Skip to content

Instantly share code, notes, and snippets.

@zhengxiaowai
Created November 6, 2017 08:38
Show Gist options
  • Save zhengxiaowai/b95d600cb2bf660cb0cc4d54898a801d to your computer and use it in GitHub Desktop.
Save zhengxiaowai/b95d600cb2bf660cb0cc4d54898a801d to your computer and use it in GitHub Desktop.
import decimal
import json
# This is a workaround for: http://bugs.python.org/issue16535
class DecimalEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, decimal.Decimal):
return int(obj)
return super(DecimalEncoder, self).default(obj)
json.dumps(result['Item'], cls=DecimalEncoder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment