项目作者: markenwerk

项目描述 :
A PHP library providing pretty printing JSON strings for PHP < 5.4
高级语言: PHP
项目地址: git://github.com/markenwerk/php-json-pretty-printer.git
创建时间: 2016-07-12T12:31:53Z
项目社区:https://github.com/markenwerk/php-json-pretty-printer

开源协议:MIT License

下载


PHP JSON Pretty Printer

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

  1. {
  2. "require": {
  3. "markenwerk/json-pretty-printer": "~1.0"
  4. }
  5. }

Usage

Autoloading and namesapce

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

Pretty printing a JSON string

Default indentation is one tab.

  1. use Markenwerk\JsonPrettyPrinter;
  2. $jsonString = json_encode($myObject);
  3. $prettyPrinter = new JsonPrettyPrinter\JsonPrettyPrinter();
  4. $prettyPrinted = $prettyPrinter
  5. ->setIndentationString(' ')
  6. ->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.