Skip to content

Instantly share code, notes, and snippets.

@timmyRS
Created June 24, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyRS/5794415983bb9d2aa062c36ad4053065 to your computer and use it in GitHub Desktop.
Save timmyRS/5794415983bb9d2aa062c36ad4053065 to your computer and use it in GitHub Desktop.
Make JSON pretty again
<?php
if(empty($argv[1]))
{
die("Syntax: php {$argv[0]} <file>");
}
$json = json_decode(file_get_contents($argv[1]), true);
if($json == NULL)
{
die("ERROR: Invalid JSON.");
}
file_put_contents($argv[1], json_encode($json, JSON_PRETTY_PRINT));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment