Skip to content

Commit

Permalink
Merge pull request #18 from jrfnl/Alternative-json-pretty-print
Browse files Browse the repository at this point in the history
Use native JSON pretty printing if available
  • Loading branch information
YahnisElsts committed Sep 10, 2014
2 parents 3d21b62 + e799ef3 commit 631a40c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions includes/Wpup/UpdateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ protected function filterLogInfo($columns) {
*/
protected function outputAsJson($response) {
header('Content-Type: application/json');
$output = json_encode($response);
if ( function_exists('wsh_pretty_json') ) {
$output = wsh_pretty_json($output);
$output = '';
if ( defined('JSON_PRETTY_PRINT') ) {
$output = json_encode($response, JSON_PRETTY_PRINT);
} elseif ( function_exists('wsh_pretty_json') ) {
$output = wsh_pretty_json(json_encode($response));
} else {
$output = json_encode($response);
}
echo $output;
}
Expand Down

0 comments on commit 631a40c

Please sign in to comment.