return a Raw format response

@param  string $data   The data
@param  int    $status The HTTP status code.
@return \Swoft\Http\Message\Server\Response when $data not jsonable
186946
public function raw(string $data = '', int $status = 200): Response
    {
        $response = $this;

        // Headers
        $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/plain');
        $this->getCharset() && $response = $response->withCharset($this->getCharset());

        // Content
        $data && $response = $response->withContent($data);

        // Status code
        $status && $response = $response->withStatus($status);

        return $response;
    }
674864
protected function respond($event, $error, $status, $payload = [])
    {
        $response = $this->events->fire($event, $payload, true);

        return $response ?: $this->response->json(arrayView('phpsoft.users::errors/authenticate', [
            'error' => $error
        ]), $status);
    }
1230615
public static function resourceJson($data = array(), $status = 200, array $headers = array())
  {
    $resource = new Resource($data);
    $etag = $resource->getEtag();

    if ( ! empty($etag)) {
      $headers['ETag'] = $etag;
    }

    unset($resource);

    return self::json($data, $status, $headers);
  }
20324
protected function jsonResponse($data = array(), $status = 200, array $headers = array(), $options = 0)
	{
		if ($data instanceof JsonSerializable) {
			$data = $data->jsonSerialize();
		} else if ($data instanceof ArrayableInterface) {
			$data = $data->toArray();
		}

		return new JsonResponse($data, $status, $headers, $options);
	}
427433
protected function returnJson($data, $httpStatus = 200)
    {
        header(HTTPToolkit::statusCodeHeader($httpStatus));
        Context::getInstance()->getResponse()->setContentHeader('application/json');
        $this->response = $this->getPsrResponse()->withBody(stream_for(json_encode($data)));
    }
819511
public static function statusToStr($status) {
        if (!is_int($status)) throw new IllegalTypeException('Illegal type of parameter $status: '.gettype($status));

        switch ($status) {
            case PGSQL_EMPTY_QUERY   : return 'PGSQL_EMPTY_QUERY';
            case PGSQL_COMMAND_OK    : return 'PGSQL_COMMAND_OK';
            case PGSQL_TUPLES_OK     : return 'PGSQL_TUPLES_OK';
            case PGSQL_COPY_OUT      : return 'PGSQL_COPY_OUT';
            case PGSQL_COPY_IN       : return 'PGSQL_COPY_IN';
            case PGSQL_BAD_RESPONSE  : return 'PGSQL_BAD_RESPONSE';
            case PGSQL_NONFATAL_ERROR: return 'PGSQL_NONFATAL_ERROR';
            case PGSQL_FATAL_ERROR   : return 'PGSQL_FATAL_ERROR';
        }
        return (string) $status;
    }
483756
public function error($data = [], $status = Response::HTTP_BAD_REQUEST, $headers = [])
    {
        return $this->response($data, $status, $headers);
    }
280488
private function respondWithJson(ResponseInterface $response, array $data, $status)
    {
        $body = $response->getBody();
        $body->rewind();
        $body->write(json_encode($data));

        $response = $response->withStatus($status);
        $response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');

        return $response;
    }
1008041
public function renderJson($data, $status = 200) {
		$app = \Slim\Slim::getInstance();

		$app->response()->status($status);
		$app->response()->header('Content-Type', 'application/json');

		$body = json_encode($data);
		$app->response()->body($body);
		$app->stop();
	}
1156489
public static function json( $data = array(), $status = 200, $beautify = true ) 
	{
		if ( !is_array( $data ) )
		{
			throw new CCException( "CCResponse::json - first argument has to be an array." );
		}

		$response = new static( CCJson::encode( $data, $beautify ), $status );
		$response->header( 'Content-Type', 'text/json' );

		return $response;
	}
535226
public function withJson($data, int $status = null, int $options = 0)
        {
            $json = json_encode($data, $options);
            if ($json === false) {
                throw new \RuntimeException(json_last_error_msg(), json_last_error());
            }
            
            $response = $this->write($json);
            $response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');
            
            if (isset($status)) {
                return $response->withStatus($status);
            }
            return $response;
        }
979472
public function composeJson(array $data = [], int $status = 200, array $config = []): SymfonyResponse
    {
        return Response::make($this->createJsonResponse($data, $config)(), $status, [
            'Content-Type' => 'application/json',
        ]);
    }
802759
public function respondExceptionError($status, $message, $status_code, $payload)
    {
        $responseData = $this->getResponseStructure($status, $payload, $message);
        $response = new JsonResponse($responseData, $status_code, $this->getHeaders());

        return $response;
    }
207121
public function json(array $data, $status = 200, $encodingOptions = 0)
    {
        return $this->response->withJson($data, $status, $encodingOptions);
    }
1299511
protected function respond($data, $status = Response::HTTP_OK, $headers = []) : JsonResponse
    {
        if ($data instanceof ElementInterface) {
            $data = new Document($data);
        }

        if ($data instanceof Document) {
            $data = $data->toArray();
        }

        return response()->json($data, $status, $headers)
            ->header('Content-Type', ApiRequestHandler::CONTENT_TYPE);
    }
240304
public function json($data = [], $status = 200, array $headers = [], $options = 0)
    {
        return new JsonResponse($data, $status, $headers, $options);
    }
482302
protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
    {
        $headers = $this->getResponse()->headers->all();

        $serializedData = [];

        foreach ($data as $key => $item) {
            if (is_array($item) && is_object($item[0])) {
                $serializedData[$key] = EntityNormalizer::normalize($item);

                unset($data[$key]);
            }

            if (is_object($item)) {
                $serializedData[$key] = EntityNormalizer::normalize([$item])[0];

                unset($data[$key]);
            }
        }

        $serializedData = array_merge($serializedData, $data);

        return new JsonResponse($serializedData, $status, $headers);
    }