-
Notifications
You must be signed in to change notification settings - Fork 461
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
JSON formatting using Gson #1125
Conversation
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.
Great PR, this will definitely get merged in some form, thanks!
Two points:
-
I think most of the classes in
com.diffplug.spotless.json.gson
can be made package-private rather than public. -
You are currently using lots of reflection. That is fine, and I'm happy to merge this PR as-is. But you might want to consider Use custom source sets and compile-only dependencies instead of reflection #524
Good point, done. Please note that I had to also put
Thank you, I completely missed this one. I could definitely deliver this as a future improvement, but would prefer not to with this PR. I'd like to use this on a corporate project as soon as possible. |
We should advertise the compile-only thing better, would #1129 have helped you?
Roger. I'll merge and release once CI completes. |
CI failed with a |
Head branch was pushed to by a user without write access
Yes, definitely. The contribution guide would be the best place for this info, that's where I looked for it as well.
Oops. sorry for that. Error fixed. |
Published in |
Out of curiosity, why not just use setPrettyPrinting? |
@ZacSweers We need to set a custom |
This PR adds support for JSON formatting using Google's Gson library.
Motivation:
simple
, based on org.json) would make this hard to implement, as its internal representation for key-value pairs does not guarantee any order. See the following examples which demonstrate thatsimple
does some kind of key ordering, but not alphabetical:Notes:
simple
for backwards compatibility.Change includes:
indentWithSpaces
,sortByKeys
,escapeHtml
, andversion
properties