-
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 #1280
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
CLAs look good, thanks! |
@@ -176,6 +176,7 @@ | |||
*/ | |||
private String indent; | |||
|
|||
private boolean prettyPrinting = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this field necessary? The indent
field seems to cover this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed it.
I think this is a pretty useful feature to have in |
@lyubomyr-shaydariv, Thanks for your review! Your proposal looks good. I could implement it. But what about just add check for indent string? smth like:
|
@wslf The
But if I'd design a new API, I'd probably would go with methods that do not allow to add characters other than However, my idea has at lease on disadvantage and would complicate things for indent strings that are stored elsewhere, let's say, as configuration. This would require a user to store both indent character and indent character count or have some defaults to these + and dynamically dispatch to either to
Anyway, the final decisions always go to the Gson development team. |
…(int count) and setPrettyPrintingByTabs(int count)
d0e26cd
to
2840d9f
Compare
I'd love to see this PR merged (or some variation), this is pretty old now. Any possibility it will get merged? |
We would like to see a more general solution. For example, something that supplies a formatter that walks through a DOM tree and prints it. |
@inder123 but does it really need to be such complicated, and doesn't this PR merely implement a minor tweak for an existing currently poorly customizable indentation feature (that's pretty old itself) rather than implementing a neat well-designed formatter from scratch? |
@lyubomyr-shaydariv It's not a minor tweak if you are introducing a new API. |
Implementation for issue #1279