Encode JsonSerializable instance response, with status 200.

@param  JsonSerializable  $action_result
@param  ResponseInterface $response
@param  int               $status
@return ResponseInterface
482514
protected function encodeJsonSerializable(JsonSerializable $action_result, ResponseInterface $response, $status = 200)
    {
        return $response->write(json_encode($action_result))->withStatus($status);
    }
391147
protected function renderToken(UserInterface $user, $statusCode = 200)
    {
        $body = [
            'token'         => $this->container->get('lexik_jwt_authentication.jwt_manager')->create($user),
            'refresh_token' => $this->attachRefreshToken($user),
            'user'          => $user->getUsername(),
        ];

        return new JsonResponse($body, $statusCode);
    }
1171870
private function transformResponseToResult(
        ResponseInterface $response,
        RequestInterface $request,
        CommandInterface $command
    ) {
        $transform = $this->responseToResultTransformer;

        return $transform($response, $request, $command);
    }
696955
public function response($result, $id, $error) {
        if ($error) { 
            $error['name'] = 'JSONRPCError';
        }
        return json_encode(array("jsonrpc" => "2.0",
                                 'result' => $result,
                                 'id' => $id,
                                 'error'=> $error));
    }
725841
public static function json($data, $status = 200, $headers = array())
    {
        $jsonHeader = array('Content-Type' => 'application/json');

        $content = json_encode($data);

        return new Response($content, $status, $jsonHeader);
    }
1347711
public function createSealedResponse(
        int $status,
        string $body,
        SealingPublicKey $key,
        array $headers = [],
        string $version = '1.1'
    ): ResponseInterface {
        $sealed = Simple::seal(
            $body,
            $key
        );
        return new Response(
            $status,
            $headers,
            Base64UrlSafe::encode($sealed),
            $version
        );
    }
1361785
public function mapResponse($success, $response)
    {
        if (array_key_exists('collection', $response)) {
            $response = array_merge($response, $response['collection']);

            unset($response['collection']);
        }

        $rawResponse = $response;
        $test = $this->config['test'];

        unset($rawResponse['isRedirect']);
        unset($rawResponse['topic']);

        if ($response['isRedirect']) {
            return (new Response())->setRaw($rawResponse)->map([
                'isRedirect'      => $response['isRedirect'],
                'success'         => $response['isRedirect'] ? false : $success,
                'reference'       => $success ? Arr::get($response, 'id') : null,
                'message'         => 'Redirect',
                'test'            => $test,
                'authorization'   => $success ? Arr::get($response, $test ? 'sandbox_init_point' : 'init_point') : null,
                'status'          => $success ? new Status('pending') : new Status('failed'),
                'errorCode'       => $success ? null : $this->getErrorCode($response),
                'type'            => null,
            ]);
        }

        return (new Response())->setRaw($rawResponse)->map([
            'isRedirect'      => false,
            'success'         => $success,
            'reference'       => $success ? $this->getReference($response) : null,
            'message'         => $success ? 'Transaction approved' : $this->getMessage($rawResponse),
            'test'            => $test,
            'authorization'   => $success ? Arr::get($response, 'id') : null,
            'status'          => $this->getStatus($response),
            'errorCode'       => $success ? null : $this->getErrorCode($response),
            'type'            => Arr::get($response, 'topic'),
        ]);
    }
1289552
public function success(int $statusCode, string $message, $data = null): JsonResponse
    {

        $this->setStatusCode($statusCode);

        $this->setMessage($message);

        $this->setData($data);


        $content['message'] = $this->getMessage();


        if (null !== $this->getCode()) {
            $content['code'] = $this->getCode();
        }


        $content['status_code'] = $this->getStatusCode();


        if (null !== $this->getData() && $this->getErrors() !== $this->getData()) {
            $content['data'] = $this->getData();
        }

        if (null !== $this->getErrors()) {
            $content['errors'] = $this->getErrors();
        }

        $content += $this->Hypermedia;

        return new JsonResponse($content, $this->getHttpStatusCode() ?: $this->getStatusCode());
    }
992117
public function json($data = [], $status = 200, array $headers = [], $options = false)
    {
        $options = ($options === false) ? JSON_PRETTY_PRINT : $options;

        return new JsonResponse($data, $status, $headers, $options);
    }
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;
    }
975838
public function response($content, $statusCode = 200)
    {
        return response()
            ->json($this->convertContent($content))
            ->setStatusCode($statusCode);
    }
1138372
public function create(
        $object,
        string $accept,
        int $status = 200,
        NormalizerContextInterface $context = null
    ): ResponseInterface {
        $body = $this->serializer->serialize($object, $accept, $context);

        $response = $this->responseFactory->createResponse($status)->withHeader('Content-Type', $accept);
        $response->getBody()->write($body);

        return $response;
    }
282754
protected function processAction($action, FormInterface $form = null, $statusCode = Response::HTTP_NO_CONTENT)
    {
        $statusCode = $this->getParameterResolver()->resolveStatusCode($statusCode);

        $this->getRestEventDispatcher()->dispatch(
            RestEvents::ACTION,
            $event = new ActionEvent($this->resource, $action, $form, $statusCode)
        );

        $view = $event->getView();
        $statusCode = $view->getStatusCode();

        return $statusCode >= 300 && $statusCode < 400
            ? $this->handleView($view)
            : $this->processView($action, $view);
    }
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);
    }
1110305
private function handleResult($result): void
    {
        if ($result instanceof ActionResultInterface) {
            $result->updateResponse($this->getApplication(), $this->getRequest(), $this->getResponse());

            return;
        }

        if ($result === null) {
            return;
        }

        $this->getResponse()->setContent(json_encode($result));
        $this->getResponse()->setHeader('Content-Type', 'application/json');
    }
919057
protected function encodeScalar($action_result, ResponseInterface $response, $status = 200)
    {
        return $response->write(json_encode($action_result))->withStatus($status);
    }
541250
def json_to_response(self, action=None, json_status=None, success_url=None,
                         json_data=None, **response_kwargs):
        
        data = {
            "status": self.get_status(json_status),
            "action": self.get_action(action),
            "extra_data": self.get_json_data(json_data or {})
        }

        if self.action == AjaxResponseAction.REDIRECT:
            data["action_url"] = success_url or self.get_success_url()
        return JsonResponse(data, **response_kwargs)