vimeo / py-money

Money class for Python 3
MIT License
125 stars 27 forks source link

Make Currency json serializable #11

Open LKay opened 5 years ago

LKay commented 5 years ago

Currency enum should be extending str as weel to make it serializable to json by default. Currently it results with the error:

TypeError: <Currency.USD: 'USD'> is not JSON serializable

Changing definition to this should solve the issue:

class Currency(str, Enum):
    ...

And calling print(json.dumps(Currency.USD)) would correctly print: "USD".