brzuchal/json-highlighter

A PHP library for syntax highlighting JSON in the terminal.

1.0.x-dev 2024-10-01 07:25 UTC

This package is auto-updated.

Last update: 2024-10-31 07:41:20 UTC


README

A simple PHP library for syntax highlighting JSON in the terminal.

Installation

Install the package via Composer:

composer require brzuchal/json-highlighter

Usage

You can use this library to highlight JSON strings in your terminal:

use Brzuchal\JsonHighlighter\JsonHighlighter;

$json = '{
"name": "John",
"age": 30,
"married": false,
"children": null
}';

echo JsonHighlighter::highlight($json);

This will output syntax-highlighted JSON in your terminal using ANSI escape codes.

Example Output

The output will look like:

{
    "name": "John",
    "age": 30,
    "married": false,
    "children": null
}

The keys will be in light blue, strings in green, numbers in white, booleans in orange, and null values in light gray.

License

Copyright (c) 2024 Michał Marcin Brzuchalski

This project is licensed under the MIT License. See the LICENSE file for details.