Skip to content

Instantly share code, notes, and snippets.

@pjdietz
Created March 11, 2015 14:53
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 pjdietz/03101173cd66c1803c93 to your computer and use it in GitHub Desktop.
Save pjdietz/03101173cd66c1803c93 to your computer and use it in GitHub Desktop.
Pretty Print JSON
#!/usr/bin/env php
<?php
$input = file_get_contents("php://stdin");
$data = json_decode($input);
if (is_null($data)) {
fwrite(STDERR, "Unable to parse JSON\n");
exit(1);
}
print json_encode($data, JSON_PRETTY_PRINT);
print "\n";
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment