PHP code example of rcubitto / json-pretty

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

    

rcubitto / json-pretty example snippets


$obj = new \Stdclass;
$obj->prop = 1;
$obj->another = 2;

\Rcubitto\JsonPretty\JsonPretty::print($obj);

$options = [
    'colors' => [
        'bracket' => 'blue',    // {}[] and object keys
        'number' => 'green',    // any is_numeric (except strings like "1")
        'string' => 'purple',
        'boolean' => 'pink',
        'null' => 'black'
    ]
];


\Rcubitto\JsonPretty\JsonPretty::print($sample, $options);
 php
\Rcubitto\JsonPretty\JsonPretty::print([
    'store' => 'Best Buy',
    'number' => 30305,
    'products' => [
        [
            'name' => 'TV',
            'cost' => 2000.00,
            'in_stock' => true
        ],
        [
            'name' => 'Phone',
            'cost' => 350.80,
            'in_stock' => false
        ],
        [
            'name' => 'Sample',
            'cost' => 0,
            'in_stock' => null
        ]
    ]
]);