def json_output(f):

    @wraps(f)
    def wrapper(*args, **kwargs):

        def jsonify_wrap(obj):
            jsonification = json.dumps(obj)
            return Response(jsonification, mimetype='application/json')
        result = f(*args, **kwargs)
        if isinstance(result, tuple):
            return (jsonify_wrap(result[0]), result[1])
        if isinstance(result, dict):
            return jsonify_wrap(result)
        if isinstance(result, list):
            return jsonify_wrap(result)
        return result
    return wrapper
def json_output(f):

    @wraps(f)
    def wrapper(*args, **kwargs):

        def jsonify_wrap(obj):
            jsonification = json.dumps(obj)
            return Response(jsonification, mimetype='application/json')
        result = f(*args, **kwargs)
        if isinstance(result, tuple):
            return (jsonify_wrap(result[0]), result[1])
        if isinstance(result, dict):
            return jsonify_wrap(result)
        if isinstance(result, list):
            return jsonify_wrap(result)
        return result
    return wrapper