Format json string.
- PHP > 5.4
- ext-json
$ composer require guanguans/json-format -v
<?php
require __DIR__.'/vendor/autoload.php';
$json = <<<'JSON'
{"name":"json-format","keywords":["json","format","pretty"],"description":"Format json string."}
JSON;
echo json_format($json);
{
"name": "json-format",
"keywords": [
"json",
"format",
"pretty"
],
"description": "Format json string."
}
$ composer test