Return a valid 200 Success json response.

@param string $message  The response message.
@param array  $data     The passed data.
@param string $redirect The redirection url.

@return \Illuminate\Http\JsonResponse
186622
public function validSuccessJsonResponse($message = 'Success', $data = [], $redirect = null)
    {
        return response()->json(
            [
                'code' => '200',
                'message' => $message,
                'data' => $data,
                'errors' => [],
                'redirect' => $redirect,
            ], 200, [], JSON_PRETTY_PRINT
        );
    }
4788
protected function fail($message = null, $validation = null)
    {
        $this->trigger('json-fail', $this, $message, $validation);
        $this->trigger('response-fail', $this, $message, $validation);

        $json = array('error' => true);

        if($message) {
            $json['message'] = $message;
        }

        if($validation) {
            $json['validation'] = $validation;
        }

        $body = json_encode($json, JSON_PRETTY_PRINT);

        $this->response
            ->set('headers', 'Content-Type', 'text/json')
            ->set('body', $body);

        return $body;
    }
56195
public function getJSON($url,$data,$headers)
    {

        $response = $this->get($url,$data,$headers);
        $response["response"] = json_encode($response["response"]); // Again decoding it back to JSON

        return $response;
    }
709493
public function successData($data, $msg = null, $extraData = [])
    {
        $return = $this->output(1, $msg, $data, $extraData);

        return $this->responseJson($return);
    }
798610
public function success($message = null, $data = array(), $return = false)
    {
        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        }
        $json = $this->jsonEncode(
            array(
                'success' => true,
                'message' => $message,
                'data' => $this->_data,
            )
        );
        if (!$return) {
            echo $json;
            Yii::app()->end();
        } else {
            return $json;
        }
    }
911088
protected function handleRedirectResponseException(GetResponseForExceptionEvent $event, RedirectResponseException $ex) {
        if (null !== $ex->getRedirectUrl()) {
            $event->setResponse(new RedirectResponse($ex->getRedirectUrl()));
        }
        return $event;
    }
933659
private function createErrorResponse($code, $message = null, array $data = [])
    {
        if (!$message) {
            $messages = $this->handler->getErrors()->getErrors();
            $message = isset($messages[$code]) ? $messages[$code] : 'Error';
        }

        $json = [
            'jsonrpc' => self::JSON_RPC_VERSION,
            'error' => [
                'code' => $code,
                'message' => $message
            ],
            'id' => $this->requestId
        ];

        if ($data) {
            $json['error']['data'] = $data;
        }

        return new JsonResponse($json, 200);
    }
462468
private function jsonResponse($data)
    {
        $response = new Response(json_encode($data));
        $response->headers->set('Content-Type', 'application/json');
        return $response;
    }
865282
public function respondWithError($code = null, $message = null, array $data = []): JsonResponse
    {
        return $this->respond([
            'status' => [
                'type' => 'error',
                'message' => $this->getDefaultMessage($code, $message),
                'code' => $code,
                'http_code' => $this->getStatusCode(),
            ],
            'exception' => $data,
        ]);
    }
442851
protected function _redirect(ServerRequest $request, Response $response) {
		$message = $request->getSession()->consume($this->_config['flashKey']);
		$url = $response->getHeader('Location')[0];
		$status = $response->getStatusCode();

		$json = JsonEncoder::encode([
			// Error and content are here to make the output the same as previously
			// with the component, so existing unit tests don't break.
			'error' => null,
			'content' => null,
			'_message' => $message,
			'_redirect' => compact('url', 'status'),
		], $this->_config['jsonOptions']);

		$response = $response->withStatus(200)
			->withoutHeader('Location')
			->withHeader('Content-Type', 'application/json; charset=' . $response->getCharset())
			->withStringBody($json);

		return $response;
	}
936874
public static function permanentRedirect($url, $externalRedirect = false) {
		/** @var Response $response */
		$response = new static();
		$response->redirect($url, $externalRedirect, self::HTTP_PERMANENT_REDIRECT);
		return $response;
	}
933471
protected function jsonResponse($data)
    {
        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
        $resultJson = $this->resultJsonFactory->create();
        $resultJson->setHeader('Content-type', 'application/json', true);
        $resultJson->setData($data);
        return $resultJson;
    }
241917
public function json($status_code, $message, $data = null)
    {
        return response()->json([
                                    'status_code' => $status_code,
                                    'message'     => $message,
                                    'data'        => $data,
                                    'request'     => \request()->all(),
                                ]);
    }
1169156
public function jsonSuccess($data = null, $message = null) {
        if (!is_array($message)) {
            $message = ['messages' => $message];
        }
        if ($data instanceof ArrayAble) {
            $data = $data->toArray();
        }
        return $this->json(array_merge(array(
            'code' => 200,
            'status' => __('success'),
            'data' => $data
        ), $message));
    }
1348089
private function executeQuery(string $url, string $data): \stdClass
    {
        $request = $this->getMessageFactory()->createRequest(
            'POST',
            $url,
            [
                'Content-Type' => 'application/json',
            ],
            $data
        );

        $body = $this->getParsedResponse($request);
        $json = json_decode($body);

        // API error
        if (!isset($json)) {
            throw InvalidServerResponse::create($url);
        }

        return $json;
    }
1314814
private function getError404RedirectionForm(ErrorRedirection $redirection)
    {
        $action = $this->generateUrl('victoire_404_redirect', ['id' => $redirection->getError()->getId()]);

        $containerId = sprintf('#404-%d-item-container', $redirection->getError()->getId());

        return $this->createForm(RedirectionType::class, $redirection, [
            'method'      => 'POST',
            'action'      => $action,
            'containerId' => $containerId,
            'attr'        => [
                'v-ic-post-to' => $action,
                'v-ic-target'  => 'closest li',
            ],
        ]);
    }
793112
public function execute($method, $url, array $data = [])
    {
        $client = new Client(['handler' => $this->handler]);

        return json_decode($client->request($method, $url, array_merge($data, self::$OPTIONS))->getBody());
    }