Add custom JSON encoder to handle attachment objects

This commit is contained in:
Patrick Smith
2019-01-23 10:30:30 -05:00
parent f553c9a9ea
commit e51a9012fd
2 changed files with 24 additions and 0 deletions

9
atst/utils/json.py Normal file
View File

@@ -0,0 +1,9 @@
from flask.json import JSONEncoder
from atst.models.attachment import Attachment
class CustomJSONEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, Attachment):
return obj.filename
return JSONEncoder.default(self, obj)