-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 custom indent for pretty printing #1279
Comments
What's the motivation? If you care about size you aren't using pretty printing. |
My team's project stores some large configuration data in the git repository as JSON. If I don't use pretty option the resulting file contains a single line with the whole JSON, so git couldn't show a difference between different versions. Currently, I use pretty JSON, but in my case, it increases the size of the JSON from 30 - 40 MB up to 100+ MB. Bigger resulting JSON also requires more RAM for converting. So, I suppose it would be cool to have such feature as a custom indent. |
I agree, if you are appending to an existing Json with either 2, 4 spaces or tab indent, it would be nice to have such a feature. I'm actually suprised there isn't. |
+1 for configurable indent size @JakeWharton , my motivation is being able to compare jsons generated with gson against json files formatted in other tools, in my case IntelliJ Idea. |
+1 for configurability! |
Already implemented in 2.8.7 release. Class
This implementation indents with tab and appends final newline:
Best regards! |
I believe @Conrad-T-Pino is right that this feature has been implemented, so the issue can be closed. |
Untested
Best regards. |
I use the pretty print for debug purposes to be able to actually read the JSON.
|
It would be great if we can specify custom indent while call pretty printing. Currently pretty printing always use 2 spaces for indent. This customization also allows to reduce size of resulting json.
Comparison table and code for generating json below:
The text was updated successfully, but these errors were encountered: