1. Go to this page and download the library: Download aalfiann/json-class-php 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/ */
aalfiann / json-class-php example snippets
use \aalfiann\JSON;
$data = [
'result'=>'just make a test!',
'data' => [
'id' => '1',
'user' => 'your name',
'email' => '[email protected]',
'website' => 'http://yourdomain.com',
'non-utf8' => 'السلام علیکم ورحمة الله وبرکاته!'
]
];
header('Content-Type: application/json');
$json = new JSON;
echo $json->encode($data,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
use \aalfiann\JSON;
$data = '{"result":"just make a test!","data":{"id":"1","user":"your name","email":"[email protected]","website":"http://yourdomain.com","non-utf8":"\u00d8\u00a7\u00d9\u0084\u00d8\u00b3\u00d9\u0084\u00d8\u00a7\u00d9\u0085 \u00d8\u00b9\u00d9\u0084\u00db\u008c\u00da\u00a9\u00d9\u0085 \u00d9\u0088\u00d8\u00b1\u00d8\u00ad\u00d9\u0085\u00d8\u00a9 \u00d8\u00a7\u00d9\u0084\u00d9\u0084\u00d9\u0087 \u00d9\u0088\u00d8\u00a8\u00d8\u00b1\u00da\u00a9\u00d8\u00a7\u00d8\u00aa\u00d9\u0087!"},"logger":{"timestamp":"2018-09-17 13:53:12","uniqid":"5b9f95a812c0f"}}';
$json = new JSON;
echo var_dump($json->decode($data,true));
use \aalfiann\JSON;
header('Content-Type: application/json');
$json = new JSON;
$json->debug=true;
echo $json->encode($data,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
use \aalfiann\JSON;
header('Content-Type: application/json');
$json = new JSON;
echo $json->withSanitizer()->withLog()->encode(['user'=>'yourname'],JSON_PRETTY_PRINT);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.