markenwerk / json-pretty-printer
A PHP library providing pretty printing JSON strings for PHP < 5.4
Installs: 2 151
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.3
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: ~4.8
This package is auto-updated.
Last update: 2021-01-18 12:10:17 UTC
README
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.