PHP code example of borisguery / json-builder

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

    

borisguery / json-builder example snippets




nBuilder\Builder\JsonBuilder;

$jb = new JsonBuilder();
$root = $jb->root('array');
$root
    ->children()
        ->string()
            ->value('Foo')
        ->end()
        ->number()
            ->value(123)
        ->end()
    ->end()
->end();

$json = $jb->build()->toJson();

echo $json;
bash
$ php composer.phar