Advertisement
puggan

/usr/local/bin/json-print

Jan 13th, 2022
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.23 KB | None | 0 0
  1. #!/bin/env php
  2. <?php
  3.  
  4. $raw = file_get_contents('php://stdin');
  5. $decoded = json_decode($raw);
  6.  
  7. echo $decoded === null ? $raw : json_encode($decoded, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
  8. echo PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement