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

Pretty print JSON #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Pretty print JSON #24

wants to merge 1 commit into from

Conversation

dantleech
Copy link
Contributor

This PR will pretty print json when print response is invoked and the Content-Type is application/json

Will add a feature/test if this is OK.

@stof
Copy link
Member

stof commented Jun 10, 2015

I'm not sure this is a good idea. It means that the body being displayed is not the response body anymore.
and it could cause weird issues in case your app is buggy and does not return valid JSON, making things very hard to debug.

@dantleech
Copy link
Contributor Author

Well, if the JSON is invalid it should revert to the original $body. For me this helped alot with debugging, but your call, if you want to close this it's fine.

@stof
Copy link
Member

stof commented Jun 10, 2015

no it won't. You don't validate the decoding of the JSON. So if decoding fails, you will reencode null, which is totally valid (it gives you $formattedJson = 'null';)

@dantleech
Copy link
Contributor Author

Hmm, yeah, I didn't read the code properly. But it could validate the JSON. :)

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