Last active
June 16, 2017 02:20
-
-
Save AhnSeongHyun/2329e79ac451edf655789f7243077ef1 to your computer and use it in GitHub Desktop.
jsonify_encoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def configure_json_encoder(app): | |
from decimal import Decimal | |
class CustomJsonEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, Decimal): | |
return str(obj) | |
if obj is None: | |
return str('') | |
return super(CustomJsonEncoder, self).default(obj) | |
app.json_encoder = CustomJsonEncoder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment