markenwerk/json-pretty-printer

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP library providing pretty printing JSON strings for PHP < 5.4

1.0.1 2016-07-15 13:01 UTC

This package is auto-updated.

Last update: 2021-01-18 12:10:17 UTC


README

Build Status Test Coverage Dependency Status SensioLabs Insight Code Climate Latest Stable Version Total Downloads License

A PHP library providing pretty printing JSON strings for PHP < 5.4 based upon this StackOverflow answer by Kendall Hopkins.

Installation

{
   	"require": {
        "markenwerk/json-pretty-printer": "~1.0"
    }
}

Usage

Autoloading and namesapce

require_once('path/to/vendor/autoload.php');

Pretty printing a JSON string

Default indentation is one tab.

use Markenwerk\JsonPrettyPrinter;

$jsonString = json_encode($myObject);
$prettyPrinter = new JsonPrettyPrinter\JsonPrettyPrinter();
$prettyPrinted = $prettyPrinter
	->setIndentationString('  ')
	->prettyPrint($jsonString);

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document.

License

PHP JSON Pretty Printer is under the MIT license.