human
Complete this python program:
def json(func, pretty=False):
assistant
#Here is the Python program you requested.

    """Format the response as JSON and set the response content type to
    JSON_CONTENT_TYPE.
    """
    @wraps(func)
    def call_and_format(self, trans, *args, **kwargs):
        jsonp_callback = kwargs.pop(JSONP_CALLBACK_KEY, None)
        if jsonp_callback:
            trans.response.set_content_type(JSONP_CONTENT_TYPE)
        else:
            trans.response.set_content_type(JSON_CONTENT_TYPE)
        rval = func(self, trans, *args, **kwargs)
        return _format_return_as_json(rval, jsonp_callback, pretty=(pretty or trans.debug))
    if (not hasattr(func, '_orig')):
        call_and_format._orig = func
    return expose(_save_orig_fn(call_and_format, func))