Skip to content

Latest commit

 

History

History
61 lines (49 loc) · 971 Bytes

readme.md

File metadata and controls

61 lines (49 loc) · 971 Bytes

PHP JSON Pretty View

PHP JSON Pretty View

Requirements

"php": "^8.3",
"illuminate/support": "^12.0"

Installation

composer require makhnanov/php-json-pretty-view

Usage

<?php

use Makhnanov\JsonPrettyView\PrettyJson;

require_once __DIR__ . '/vendor/autoload.php';

$asString = <<<JSON
{
    "id": 1000,
    "true": true,
    "false": false,
    "null": null,
    "string": "null",
    "second string": "str sub str",
    "array": [
        1,
        2
    ],
    "last string": "finish"
}
JSON;

json_pretty($asString);

// OR

pretty_json($asString);

// OR

echo PrettyJson::highlightCli([
    'id' => 1000,
    'true' => true,
    'false' => false,
    'null' => null,
    'string' => "null",
    'second string' => "str sub str",
    'array' => [
        1, 2,
    ],
    'last string' => "finish",
]);

echo PHP_EOL;