diff --git a/src/Opengraph/Writer.php b/src/Opengraph/Writer.php index 0ebd1f0..9ad9bf3 100644 --- a/src/Opengraph/Writer.php +++ b/src/Opengraph/Writer.php @@ -48,6 +48,25 @@ public function prepend($property, $content) return $this->addMeta($property, $content, self::PREPEND); } + /** + * Write Opengraph from Json + * + * @param String $json + * @return \Opengraph\Writer return a new Writer + */ + public static function fromJson($json) + { + $jsonDecoded = json_decode($json, true); + + $writer = new Writer(); + + array_walk_recursive($jsonDecoded, function($v, $k) use ($writer) { + $writer->append($k, $v); + }); + + return $writer; + } + /** * Render all meta tags *