PHP JSON Pretty Print: Display data types like human-readable JSON values

Recommend this page to a friend!
  Info   Example   View files (6)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 127 This week: 1All time: 9,085 This week: 255
Version License PHP version Categories
json_formatter 1.0.0BSD License5HTML, PHP 5, Data types
Description Author

This class can display data types like human-readable JSON values.

It takes the a variable value as parameter and encodes it as JSON object.

The class processes the JSON output and reformats it to display nicely in a HTML Web page.

Innovation Award
PHP Programming Innovation award nominee
July 2019
Number 10
Many developers need to check values used in their applications variables. One easy way of seeing those values is to display them on a Web page.

Nowadays, many developers prefer to use the JSON format to display application variable values. PHP supports the JSON format but sometimes the output of the JSON encoding functions is not very readable.

This class provides a solution to display application variable values using the JSON format in a way that can be more readable for all developers.

Manuel Lemos
Picture of chrys ugwu
  Performance   Level  
Name: chrys ugwu <contact>
Classes: 9 packages by
Country: Nigeria Nigeria
Age: 27
All time rank: 20789 in Nigeria Nigeria
Week rank: 13 3 in Nigeria Nigeria
Innovation award
Innovation award
Nominee: 3x

Details

JSON_Formatter

Allows you to pretty-print JSON data in a human-readable format

Latest Stable Version License Latest Stable Version Minimum PHP Version

Installation

You can download the Latest release version as a standalone, alternatively you can use Composer for optional dependencies such as PHPUnit.

$ composer require ghostff/json-formatter

Or add:

{
    "require": {
        "ghostff/json-formatter": "^1.0"
    }
}

to your `composer.json`

Usage:

<?php

$source = array (
  array ( 'points' => 1, 'name' => 'Peter'),
  array ( 'points' => 5, 'name' => 'Mike'),
  array ( 'points' => 2, 'name' => 'John Zoo'),
  array ( 'points' => 2, 'name' => 'John Ab')
);

echo Json::encode($source);

Outputs:

alt tag

  Files  
File Role Description
src (1 file)
composer.json Data Auxiliary data
index.php Example Example
README.md Doc. Documentation
SS.png Data Auxiliary data
text.php Aux. Auxiliary script

  Files  /  src  
File Role Description
   Json.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:127
This week:1
All time:9,085
This week:255

For more information send a message to info at phpclasses dot org.