diff --git a/server/atheneum/utility.py b/server/atheneum/utility.py new file mode 100644 index 0000000..53f8abd --- /dev/null +++ b/server/atheneum/utility.py @@ -0,0 +1,17 @@ +from datetime import date + +import rfc3339 +from flask.json import JSONEncoder + + +class CustomJSONEncoder(JSONEncoder): + def default(self, obj): + try: + if isinstance(obj, date): + return rfc3339.format(obj) + iterable = iter(obj) + except TypeError: + pass + else: + return list(iterable) + return JSONEncoder.default(self, obj)