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
sortByKeysis enabled, objects are recursively sorted but arrays are skipped. Take a look at this JSON for example:{ "array": [ { "b": "b", "a": "a" } ] }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
sortByKeysInArraysto 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.