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

Support for pretty-printing JSON #70

Closed
andrew-d opened this issue Apr 19, 2013 · 2 comments
Closed

Support for pretty-printing JSON #70

andrew-d opened this issue Apr 19, 2013 · 2 comments

Comments

@andrew-d
Copy link
Contributor

Hey there,

It would be kinda cool if we could pretty-print returned json (by setting the "indent" parameter on json.dumps here). I really like being able to explore APIs that do this - especially from the command line.

One simple method would be to add a settings variable to the flask_restful.representations.json module that you can directly set, e.g. like this:

import flask_restful.representations.json

flask_restful.representations.json.settings['indent'] = 4

If this sounds like something that would be allowed, I'd be happy to send a pull request.

Thanks.

@gbin
Copy link
Contributor

gbin commented Apr 19, 2013

I like it, I would link it to the debug mode.

@andrew-d
Copy link
Contributor Author

Hm, that's not a bad idea either. I wouldn't mind having a method of manually setting it, though, even in non-debug mode, though. I know that Stripe, for example, will serve pretty-printed JSON to everybody. For example: curl -ik https://api.stripe.com/v1/ gives properly pretty-printed 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

No branches or pull requests

3 participants