aws_lambda_decorators/decorators.py
def response_body_as_json(func):
    """
    Convert the dictionary response of the wrapped/decorated function to a json string literal.

    Usage:
        @response_body_as_json
        def lambda_handler():
            return {"statusCode": 200, "body": {"key": "value"}}

        will return {"statusCode": 200, "body": "{"key":"value"}"}
    """
    def wrapper(*args, **kwargs):
        response = func(*args, **kwargs)
        if "body" in response:
            try:
                response["body"] = json.dumps(response["body"])
            except TypeError:
                return failure(NON_SERIALIZABLE_ERROR_MESSAGE, 500)
        return response
    return wrapper

    Convert the dictionary response of the wrapped/decorated function to a json string literal.

    Usage:
        @response_body_as_json
        def lambda_handler():
            return {"statusCode": 200, "body": {"key": "value"}}

        will return {"statusCode": 200, "body": "{"key":"value"}"}
    
Convert the dictionary response of the wrapped/decorated function to a json string literal.


Convert the dictionary response of the wrapped / decorated function to a json string literal .
def response_body_as_json(func):
    def wrapper(*args, **kwargs):
        response = func(*args, **kwargs)
        if "body" in response:
            try:
                response["body"] = json.dumps(response["body"])
            except TypeError:
                return failure(NON_SERIALIZABLE_ERROR_MESSAGE, 500)
        return response
    return wrapper
def response_body_as_json ( func ) : def wrapper ( * args , ** kwargs ) : response = func ( * args , ** kwargs ) if "body" in response : try : response [ "body" ] = json . dumps ( response [ "body" ] ) except TypeError : return failure ( NON_SERIALIZABLE_ERROR_MESSAGE , 500 ) return response return wrapper
Convert the dictionary response of the wrapped/decorated function to a json string literal.
Convert the dictionary response of the wrapped / decorated function to a json string literal .
"""
    Convert the dictionary response of the wrapped/decorated function to a json string literal.

    Usage:
        @response_body_as_json
        def lambda_handler():
            return {"statusCode": 200, "body": {"key": "value"}}

        will return {"statusCode": 200, "body": "{"key":"value"}"}
    """
func