-
Notifications
You must be signed in to change notification settings - Fork 459
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
Sort by keys inside json arrays #1546
Conversation
I think the behavior you have implemented is the correct behavior, and the old behavior was a bug. Labelling it as "potentially breaking" is perfect, alerts people who may have come to rely on the bug. If anyone wants to add a flag in the future "sortByKeysExceptArrayElements" to restore the previous behavior, I would merge that PR so that they could keep the old behavior. To get merged, this PR needs
|
Thanks for comments, a key to restore the old behaviour is even better! Will do everything tomorrow and send an update. |
All done. As we consider this as a bug, I didn't add a new test but modified the existing one. |
Tests are failing. Looks like the plugin integration tests don't like the changes. |
Indeed I didn't run integration tests. Fixed and reran everything locally, it should pass now. |
Implemented in |
Hi team!
I'd like to propose an improvement of JSON formatting feature implemented in #1125
Now, if
sortByKeys
is enabled, objects are recursively sorted but arrays are skipped. Take a look at this JSON for example:Note that keys are not sorted now and will not be sorted after applying the formatter. My proposal is to sort these keys too.
I'm not sure whether existing configuration property should be reused as this changes the behaviour of GSON formatter. If it's not acceptable I can add another property like
sortByKeysInArrays
to preserve backwards compatibility. When we choose which one is better, I'll certainly add some tests.Let me know, what do you think about it.