Make the JSON response

@param int $status_code HTTP status code to return
@param array|null $body JSON body of the request

@return HTTPResponse JSON response
427102
public function makeJsonReponse($status_code, $body)
    {
        $this->getResponse()->setBody(json_encode($body, JSON_UNESCAPED_SLASHES));
        $this->getResponse()->setStatusCode($status_code);
        $this->getResponse()->addHeader("Content-type", "application/json");

        return $this->getResponse();
    }
641100
protected function createResponse($statusCode, $contentType)
    {
        switch ($statusCode) {
            case 200:
            case 201:
                return $this->createContent($contentType);
            default:
                // fail on error
                if ($this->curlOptions[45]) {
                    throw new LushRequestException($this, ['message' => sprintf('%d - Mocked server error', $statusCode), 'code' => $statusCode, 'response' => 'false']);
                }

                return json_encode(['url' => $this->ch, 'status' => sprintf('Error: %d', $statusCode)]);
        }
    }
370471
public function thenRespond($statusCode, $body)
    {
        $response = ResponseBuilder::create($statusCode)->andBody($body)->build()[1];

        return $this->expectation->setResponse($response);
    }
1091019
public function setStatusCode(int $statusCode, string $statusText = null)
    {
        $this->statusCode = $statusCode;

        if ($statusText === null && isset(ResponseHeaders::$statusTexts[$statusCode])) {
            $this->statusText = ResponseHeaders::$statusTexts[$statusCode];
        } else {
            $this->statusText = $statusText;
        }
    }
241917
public function json($status_code, $message, $data = null)
    {
        return response()->json([
                                    'status_code' => $status_code,
                                    'message'     => $message,
                                    'data'        => $data,
                                    'request'     => \request()->all(),
                                ]);
    }
234118
public function resourceJson($data = array(), $status = 200, array $headers = array())
  {
    $headers = array_merge($headers, $this->getRequestLimitHeader());
    $headers = array_merge($headers, $this->getConfig('headers'));

    return $this->getResponse()->resourceJson($data, $status, $headers);
  }
1176861
public function response($statusCode = null)
        {
            $response = $this->factory(__NAMESPACE__ . '\Response');

            if (is_numeric($statusCode)) {
                $response->status($statusCode);
            }

            return $response;
        }
1299647
protected function getCodeResponse($statusCode)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();

        return $responses->getResponse($statusCode, $outputMediaType, null, $this->supportedExtensions);
    }
479457
protected function respond($response, $status, $body)
    {
        $response->status($status);

        $response->end($body);
    }
710838
function Response(statusCode, headers, body) {
  this.statusCode = statusCode;
  this.headers = {};
  for (var key in headers) {
    this.headers[key.toLowerCase()] = headers[key];
  }
  this.body = body;
}
186400
protected function readResponse($statusCode, $responseBody)
    {
        $unserialized = null;

        switch ($statusCode) {
            case 200:
            case 201:
                $unserialized = $this->unserialize($responseBody);
                break;
            case 400:
                $exception = null;
                $response  = json_decode($responseBody);

                foreach ($response as $error) {
                    $cieloError = new CieloError($error->Message, $error->Code);
                    $exception  = new CieloRequestException('Request Error', $statusCode, $exception);
                    $exception->setCieloError($cieloError);
                }

                throw $exception;
            case 404:
                throw new CieloRequestException('Resource not found', 404, null);
            default:
                throw new CieloRequestException('Unknown status', $statusCode);
        }

        return $unserialized;
    }
1201243
static function json( $data, $code = 200 ) {
        return (new Response())
            ->setCode($code)
            ->setContent(json_encode($data))
            ->setContentType('application/json');
    }
207121
public function json(array $data, $status = 200, $encodingOptions = 0)
    {
        return $this->response->withJson($data, $status, $encodingOptions);
    }
382891
public static function json($data = array(), $status = 200, array $headers = array())
	{
		if ($data instanceof ArrayableInterface)
		{
			$data = $data->toArray();
		}

		return new JsonResponse($data, $status, $headers);
	}
979472
public function composeJson(array $data = [], int $status = 200, array $config = []): SymfonyResponse
    {
        return Response::make($this->createJsonResponse($data, $config)(), $status, [
            'Content-Type' => 'application/json',
        ]);
    }
1100712
protected function createJsonApiResponse(
        ?string $content,
        int $statusCode,
        array $headers = [],
        $addContentType = true
    ) {
        if ($addContentType === true) {
            $headers[self::HEADER_CONTENT_TYPE] = $this->getMediaType()->getMediaType();
        }

        return $this->createResponse($content, $statusCode, $headers);
    }
560483
public function respond(array $data, $status = 200, $code, array $headers = [], $options = 0)
    {
        return $this->response->json(
            array_merge(compact('status', 'code'), $data), $status, $headers, $options
        );
    }