Skip to content

Instantly share code, notes, and snippets.

@sugiana
Last active December 23, 2015 02:49
Show Gist options
  • Save sugiana/6569678 to your computer and use it in GitHub Desktop.
Save sugiana/6569678 to your computer and use it in GitHub Desktop.
import json
from decimal import Decimal
def json_format(v):
if type(v) is Decimal:
return int(v)
return v
n = Decimal('8')
v = json.dumps(n, default=json_format)
print([v])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment