protected function addJsonFrontmatter($lines)
    {
        if (!function_exists("json_decode")) {
            throw new Exception("Missing JSON support, perhaps install JSON module with PHP.");
        }

        $text = implode("\n", $lines);
        $parsed = json_decode($text."\n", true);

        if (is_null($parsed)) {
            throw new Exception("Failed parsing JSON frontmatter.");
        }

        if (!is_array($parsed)) {
            $parsed = [$parsed];
        }

        $this->frontmatter = array_merge($this->frontmatter, $parsed);
    }