PHP code example of getdkan / rooted-json-data

1. Go to this page and download the library: Download getdkan/rooted-json-data 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/ */

    

getdkan / rooted-json-data example snippets


$json = '{"number":3}';
$schema = '{"type": "object","properties": {"number":{ "type": "number" }}}';
$data = new RootedJsonData($json, $schema);
echo $data->{"$.number"}; // 3
echo $data->{"$[number]"}; // 3
echo "{$data}"; // {"number":3}
$data->{"$.number"} = "three"; // EXCEPTION