PHP code example of aywan / json-ast

1. Go to this page and download the library: Download aywan/json-ast library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aywan / json-ast example snippets



declare(strict_types=1);

use \Aywan\JsonAst\JsonAstParser;

$json = <<<JSON
{
    "title": "hello world!",
    "content": [
        {"type": "h1", "value": "hello"},
        {"type": "size", "value": 123}
    ],
    "props": {"width": 85.33}
}
JSON;

$ast = (new \Aywan\JsonAst\JsonAstParser())->parse();
$hello = $ast->getRoot()
    ->getProperty('content')[0]
    ->getProperty('value')
    ->getPhpValue()
;
echo $hello; // hello