docs: def render_to_json(response, request=None, **kwargs):
      """
      Creates the main structure and returns the JSON response.
      """
      # determine the status code
      if hasattr(response, 'status_code'):
          status_code = response.status_code
      elif issubclass(type(response), Http404):
          status_code = 404
      elif issubclass(type(response), Exception):
          status_code = 500
          logger.exception(str(response), extra={'request': request})
          
          if settings.DEBUG:
              import sys
              reporter = ExceptionReporter(None, *sys.exc_info())
              text = reporter.get_traceback_text()
              response = HttpResponseServerError(text, content_type='text/plain')
          else:
              response = HttpResponseServerError("An error occured while processing an AJAX request.", content_type='text/plain')
      else:
          status_code = 200
  
      # creating main structure
      data = {
          'status': status_code,
          'statusText': REASON_PHRASES.get(status_code, 'UNKNOWN STATUS CODE'),
          'content': response
      }
  
      return JSONResponse(data, **kwargs)