Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 141 | | All time: 9,202 This week: 488 |
|
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
 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 |
| |
 |
|
Innovation award
 Nominee: 4x |
|
Example
<?php
require 'src/Json.php';
Json::setBreak('<br>');
Json::setIndent('<span style=\'margin-left:20px;display:block\'>', '</span>');
Json::allowFont(true, 'Lucida Console, Monaco, monospace');
$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);
?>
|
Details
JSON_Formatter
Allows you to pretty-print JSON data in a human-readable format

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:

|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.