code: def dump_json_body(handler):
      
      @wraps(handler)
      def wrapper(event, context):
          response = handler(event, context)
          if 'body' in response:
              try:
                  response['body'] = json.dumps(response['body'])
              except Exception as exception:
                  return {'statusCode': 500, 'body': str(exception)}
          return response
      return wrapper
docs: Automatically serialize response bodies with json.dumps.
  
  Returns a 500 error if the response cannot be serialized
  
  Usage::
  
    >>> from lambda_decorators import dump_json_body
    >>> @dump_json_body
    ... def handler(event, context):
    ...     return {'statusCode': 200, 'body': {'hello': 'world'}}
    >>> handler({}, object())
    {'statusCode': 200, 'body': '{"hello": "world"}'}