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

Add indentation to json dump #747

Closed
sina-rostami opened this issue Jan 21, 2024 · 2 comments
Closed

Add indentation to json dump #747

sina-rostami opened this issue Jan 21, 2024 · 2 comments
Labels
feature Code based project improvement

Comments

@sina-rostami
Copy link
Contributor

Hi all,

I was trying to save the request body (a JSON) to a file.
It can be done using wvalue::dump() method to return a string and then write the string in a file.

But, it's not pretty and the JSON won't be easily readable. So, I think it would be great if we could have an indentation option in wvalue::dump() method.

Regards.

sina-rostami pushed a commit to sina-rostami/Crow that referenced this issue Jan 21, 2024
sina-rostami added a commit to sina-rostami/Crow that referenced this issue Jan 21, 2024
@gittiver gittiver added the feature Code based project improvement label Jan 21, 2024
sina-rostami added a commit to sina-rostami/Crow that referenced this issue Jan 23, 2024
@MichaelSB
Copy link
Contributor

Why not feed the file to some json-formatter/pretty-printer in the case you need to read it? Something like jq? I understand your patch does not change the API. I just do not see much use in making the indentation internal to crow.

@sina-rostami
Copy link
Contributor Author

sina-rostami commented Jan 24, 2024

Why not feed the file to some json-formatter/pretty-printer in the case you need to read it? Something like jq? I understand your patch does not change the API. I just do not see much use in making the indentation internal to crow.

Dumping in a pretty way is a feature that JSON libraries normally provide. Users also could have fed the body to an external JSON parser tool in case of their need! Crow provides JSON support natively as a feature on top of the web framework. So, I think having the feature of indentation in JSON dump will also lead to a better experience for users as they don't need an external tool (like jq) to make their JSON dump pretty.

sina-rostami added a commit to sina-rostami/Crow that referenced this issue Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Code based project improvement
Projects
None yet
Development

No branches or pull requests

3 participants