public function addToJson($key, $value)
    {
        // Remove leftover linebreaks.
        $value = trim(preg_replace("/\r|\n/", "", $value));
        if ($value === '') {
            unset($this->json[$key]);
        } else {
            $this->json[$key] = $value;
        }

        return $this;
    }