Created
June 24, 2018 15:27
-
-
Save timmyRS/5794415983bb9d2aa062c36ad4053065 to your computer and use it in GitHub Desktop.
Make JSON pretty again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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