<reponame>derektruong/feeds-recommendation-system<filename>server/api/utils.py
from flask.json import JSONEncoder
from bson import json_util, ObjectId
from datetime import datetime, timedelta

class MongoJsonEncoder(JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            return obj.strftime("%Y-%m-%d %H:%M:%S")
        if isinstance(obj, ObjectId):
            return str(obj)
        return json_util.default(obj, json_util.CANONICAL_JSON_OPTIONS)
from flask.json import JSONEncoder
from bson import json_util, ObjectId
from datetime import datetime, timedelta

class MongoJsonEncoder(JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            return obj.strftime("%Y-%m-%d %H:%M:%S")
        if isinstance(obj, ObjectId):
            return str(obj)
        return json_util.default(obj, json_util.CANONICAL_JSON_OPTIONS)