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 output #132

Open
thomasvnoort opened this issue Jun 24, 2015 · 5 comments
Open

Pretty-print JSON output #132

thomasvnoort opened this issue Jun 24, 2015 · 5 comments

Comments

@thomasvnoort
Copy link
Member

It would be great if there would be a way to instruct rest to pretty-print JSON output. Many web services offer this by passing a pretty query parameter. I understand that this will reserve a name, so it should definitely be optional and configurable.

@hesselink
Copy link
Member

Sounds good! Note that if you're on the command line, you can pipe your output through e.g. python -m json.tool or something like jq. Browsers generally also pretty-print json in their debuggers. What's your use case for this?

@thomasvnoort
Copy link
Member Author

It's just a matter of convenience. I use Safari mostly and I don't think I can get Safari to pretty-print, but having a query parameter saves me from opening the debugger all the time anyway. Also, I use curl a lot and I can pipe it through some pretty-printer indeed. However, any output that is not JSON will fail in the pretty-printer with a weird error message. Then I have to think about getting curl to also print the error code somewhere, etc. Having a pretty query parameter makes life just a little bit easier :)

@octopuscabbage
Copy link

I'll look into this.

@octopuscabbage
Copy link

Can you better explain what you would like to see? I'm not sure I'm quite getting it.

@bergmark
Copy link
Member

@thomasvnoort is on vacation...

We discussed it a bit. We would like something that adds a pretty parameter (name might be customizable) to every end point with json output.

One idea is to have prettyJsonO/prettyXmlO combinators. When writing an api you can make sure to just use that instead of the normal combinators. I think this needs #20. This means you could forget it, but in practice you can have a re-export module that only exposes the combinators you want to us.

Another way is to implement it directly in the driver, that could be done right now. It would require some way to configure this, probably a parameter to apiToHandler. This would apply it to all matching handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants