Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native json pretty printing if available #18

Merged
merged 2 commits into from
Sep 10, 2014

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Sep 9, 2014

JSON_PRETTY_PRINT constant has been available since PHP5.4, so let's use it.

if ( function_exists('wsh_pretty_json') ) {
$output = wsh_pretty_json($output);
$output = '';
if ( defined('JSON_PRETTY_PRINT') && JSON_PRETTY_PRINT ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the && JSON_PRETTY_PRINT part necessary? I think defined() already covers the existence check. It is also possible (though unlikely) that in a future PHP version the value of the constant could be something falsy like 0, which would make the condition fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are of course completely right, must not have been properly awake yet when I did this ;-)

YahnisElsts added a commit that referenced this pull request Sep 10, 2014
Use native JSON pretty printing if available
@YahnisElsts YahnisElsts merged commit 631a40c into YahnisElsts:master Sep 10, 2014
@jrfnl jrfnl deleted the Alternative-json-pretty-print branch September 10, 2014 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants