PHP code example of cruxoft / bolt-json

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

    

cruxoft / bolt-json example snippets


use Bolt\Json;

try
{
    $json = Json::encode(array("hello" => "world"));
}
catch (\Exception $exception)
{
    die($exception->getMessage());
}

var_dump($json);

use Bolt\Json;

try
{
    $json = Json::decode('{"hello":"world"}');
}
catch (\Exception $exception)
{
    die($exception->getMessage());
}

var_dump($json);

use Bolt\Json;

var_dump(Json::validate('{"hello":"world"}'));
var_dump(Json::validate('{"hello":"world"x}'));

use Bolt\Json;

$json = new Json(array("hello" => "world"));
var_dump($json->toString());