Parse the JSON from an API response. We do this in a decorator so that our
    Twisted library can reuse the underlying functions

def json_twisted_response(f):
    """
    Parse the JSON from an API response. We do this in a decorator so that our
    Twisted library can reuse the underlying functions
    """

    def wrapper(*args, **kwargs):
        response = f(*args, **kwargs)
        response.addCallback(lambda x: json.loads(x))
        return response

    wrapper.func = f
    wrapper = util.mergeFunctionMetadata(f.func, wrapper)
    return wrapper