Skip to content

PrettyJSON

Keramat Jokar edited this page May 13, 2024 · 2 revisions

How to use

<?php

// Example data
$data = [
    "example" => "test",
    "test" => [
        "test" => "example"
    ]
];

// Load the file
require_once('application/libraries/prettyjson.php');

// Format it nicely with new lines, indentation etc.
$json = new PrettyJSON($data);

// Write to file
$file = fopen("myfile.json", "w");
fwrite($file, $json->get());
fclose($file);

__construct($raw)

Initialize the processing

Mixed $raw

[String] get()

Get the prettified JSON

Clone this wiki locally