Safely encode and decode JSON
You can install the package via composer:
composer require ghostwriter/json
You can also star (🌟) this repo to find it easier later.
use \Ghostwriter\Json\Json;
$json = new Json();
$encode = $json->encode(['foo'=>'bar']);
// {"foo":"bar"}
$json->validate($encode); // true
$decode = $json->decode($encode);
// ['foo'=>'bar']
$prettyPrint = true;
$json->encode($decode, $prettyPrint);
// {
// "foo":"bar"
// }
Please see CHANGELOG.md for more information on what has changed recently.
Please see LICENSE for more information on the license that applies to this project.
Please see SECURITY.md for more information on security disclosure process.