src/Valkyrja/Http/NativeJsonResponse.php
public function setData(array $data = []): JsonResponse
    {
        $content = json_encode($data, $this->encodingOptions);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(json_last_error_msg());
        }

        return $this->setJson($content);
    }
public function setData(array $data = []): JsonResponse
    {
        $content = json_encode($data, $this->encodingOptions);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(json_last_error_msg());
        }

        return $this->setJson($content);
    }
Sets the data to be sent as JSON.

@param array $data [optional] The data to set

@throws \InvalidArgumentException

@return \Valkyrja\Http\JsonResponse