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);
    }
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);
    }
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 ) ; }
Extract JSON frontmatter from text and merge into existing frontmatter.

@param array $lines the JSON to parsed.

@return void.
Extract JSON frontmatter from text and merge into existing frontmatter .