PHP code example of swaggest / json

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

    

swaggest / json example snippets


$data = array(
    'val' => 'hello!',
    'callback' => new \Swaggest\Json\RawJson('function(){alert("hello!")}')
);

$json = (string)(new \Swaggest\Json\Json($data));
$this->assertSame('{"val":"hello!","callback":function(){alert(\"hello!\")}}', $json);