2017 © Pedro Peláez
 

library pretty-json

The new JSON pretty print approach.

image

jdelta/pretty-json

The new JSON pretty print approach.

  • Wednesday, April 18, 2018
  • by jdelta
  • Repository
  • 0 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

pretty-json

The new JSON pretty print approach., (*1)

Example:, (*2)

require __DIR__ . '/../vendor/autoload.php';

use jDelta\PrettyJson;

$myData = [
    'service_url' => 'http://example.com/api/my-friends',
    'success' => true,
    'data' => [
        ['id'=>1, 'name'=>'Bill Gates', 'age' => 62],
        ['id'=>2, 'name'=>'Elon Musk', 'age' => 46],
        ['id'=>3, 'name'=>'Mark Zuckerberg', 'age' => 33]
    ],
    'total' => 3,
    'response_time' => '0.0014s'
];

//Before
echo '

';
echo json_encode($myData, JSON_PRETTY_PRINT);
echo '
'; //Now echo '
';
echo PrettyJson::getPrettyPrint(json_encode($myData));
echo '
';

Result before:

{
    "service_url": "http:\/\/example.com\/api\/my-friends",
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "Bill Gates",
            "age": 62
        },
        {
            "id": 2,
            "name": "Elon Musk",
            "age": 46
        },
        {
            "id": 3,
            "name": "Mark Zuckerberg",
            "age": 33
        }
    ],
    "total": 3,
    "response_time": "0.0014s"
}

Result now:

{
    "service_url": "http://example.com/api/my-friends",
    "success": true,
    "data": [
        {"id": 1, "name": "Bill Gates", "age": 62},
        {"id": 2, "name": "Elon Musk", "age": 46},
        {"id": 3, "name": "Mark Zuckerberg", "age": 33}
    ],
    "total": 3,
    "response_time": "0.0014s"
}

The Versions

18/04 2018

dev-master

9999999-dev https://jdelta.github.io/pretty-json

The new JSON pretty print approach.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Jaime Cruz

json print pretty prettyprint json_encode horizontal json_pretty_print

18/04 2018

v1.0

1.0.0.0 https://jdelta.github.io/pretty-json

The new JSON pretty print approach.

  Sources   Download

MIT

by Jaime Cruz

json print pretty prettyprint json_encode horizontal json_pretty_print