def json_serial(val):

    if isinstance(val, datetime):
        return val.isoformat()

    if isinstance(val, rethinkdb.ast.Now):
        return datetime.now().isoformat()

    return val
Tell `json.dumps` how to convert non-JSON types.
dataset/ETHPy150Open heiskr/sagefy/server/modules/util.py/json_serial