Return json response.

@param array|\JsonSerializable $data
@param int $httpStatus
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)));
    }
207121
public function json(array $data, $status = 200, $encodingOptions = 0)
    {
        return $this->response->withJson($data, $status, $encodingOptions);
    }
483756
public function error($data = [], $status = Response::HTTP_BAD_REQUEST, $headers = [])
    {
        return $this->response($data, $status, $headers);
    }
534281
public function withJson($data, $status = null, $encodingOptions = JSON_ENCODE_OPTION)
    {
        return parent::withJson($data, $status, $encodingOptions);
    }
466159
public function html($data, $status = HttpMessage::HTTP_OK)
    {
        $this->withStatusCode($status)
            ->withHeader('content-type', 'text/html')
            ->getBody()->write((string)$data);
        return $this;
    }
74805
public function json( $data = [], $status = 200, array $headers = [], $options = 0 )
	{
		if ( $data instanceof Arrayable && !$data instanceof JsonSerializable )
			$data = $data->toArray();

		return new JsonResponse( $data, $status, $headers, $options );
	}
587702
public function json($data, $strict = false): ResponseInterface
    {
        if (\is_resource($data)) {
            throw new \InvalidArgumentException('Cannot JSON encode resources');
        }

        if (\is_array($data) && !isset($data['ret'])) {
            $data['ret'] = 0;
            $data['msg'] = '';
        }

        $data = Json::encode($data,
            JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES
        );

        return $this->print($data, $strict ? 'application/json' : null);
    }
975838
public function response($content, $statusCode = 200)
    {
        return response()
            ->json($this->convertContent($content))
            ->setStatusCode($statusCode);
    }
1086011
public function respond($content, $status = 200)
    {
        $transformed = $this->transform($content);

        return $this->responseFactory->json($transformed, $status);
    }
580555
public function serializeSingleObject(array $data, $type,  $statusCode = Response::HTTP_OK)
    {
        $model = new ResponseModel($data, $type);

        return new JsonResponse($model->getBody(), $statusCode);
    }
826258
public function json($data, $status = 200)
    {
        $this->header('Content-Type: application/json');

        $this->statusCode($status);

        return json_encode($data);
    }
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);
    }
625805
protected function renderJson($data, $callback = null, $status = 200, $headers = array()) {
		// Check if a output action has be already performed
		$this->_checkIfPerformed();

		// Create a JSON response
		$jsonResponse = \Symfony\Component\HttpFoundation\JsonResponse::create($data, $status, $headers);

		// Set callback
		if ( null !== $callback )
			$jsonResponse->setCallback($callback);

		// Add request informationen
		$jsonResponse->prepare($this->application->requestStack->getCurrentRequest());

		// Replace response object
		$this->application->response = $jsonResponse;
	}
333789
def jsonify(self,
                data: Any,
                code: Union[int, Tuple[int, str, str]] = HTTPStatus.OK,
                headers: Optional[Dict[str, str]] = None,
                ):
        
        return jsonify(data), code, headers or {}
757161
protected function respond($event, $error, $status, $payload = [])
    {
        $response = $this->events->fire($event, $payload, true);

        $jsonApiError = new JsonApiError(str_replace('_', ' ', $error));
        $jsonApiError->setStatusCode($status);

        return $response ?: $this->response->json(['errors' => [$jsonApiError]], $status);
    }
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;
    }
1017242
public function respondWithSuccess(array $data = []): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_OK)->respond([
            'status' => [
                'http_code' => $this->getStatusCode(),
            ],
            'data' => $data,
        ]);
    }