src/Valkyrja/Valkyrja.php
public function json(array $data = [], int $statusCode = StatusCode::OK, array $headers = []): JsonResponse
    {
        /** @var JsonResponse $response */
        $response = $this->container()->getSingleton(JsonResponse::class);

        if (\func_num_args() === 0) {
            return $response;
        }

        return $response->createJson('', $statusCode, $headers, $data);
    }
public function json(array $data = [], int $statusCode = StatusCode::OK, array $headers = []): JsonResponse
    {
        /** @var JsonResponse $response */
        $response = $this->container()->getSingleton(JsonResponse::class);

        if (\func_num_args() === 0) {
            return $response;
        }

        return $response->createJson('', $statusCode, $headers, $data);
    }
Return a new json response from the application.

@param array $data       [optional] An array of data
@param int   $statusCode [optional] The status code to set
@param array $headers    [optional] The headers to set

@throws \InvalidArgumentException

@return \Valkyrja\Http\JsonResponse