Skip to content
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

Remove MapperFeature.SORT_CREATOR_PROPERTIES_BY_DECLARATION_ORDER from 3.0; make logic default #4589

Closed
cowtowncoder opened this issue Jun 19, 2024 · 4 comments
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x
Milestone

Comments

@cowtowncoder
Copy link
Member

Describe your Issue

#4580 added new MapperFeature.SORT_CREATOR_PROPERTIES_BY_DECLARATION_ORDER to prevent alphabetic sorting from affecting order of Creator properties for serialization (in case of MapperFeature. SORT_CREATOR_PROPERTIES_FIRST enabled).
This is necessary due to logic of lexicographic (~= "alphabetic") sorting which, as of 2.18, will separately sort Creator properties lexicographically too, if MapperFeature.SORT_PROPERTIES_ALPHABETICALLY is enabled.

But such sorting makes little sense. Instead, for 3.0, let's leave only 2 settings:

  • MapperFeature.SORT_PROPERTIES_ALPHABETICALLY for enabling lexicographic sorting, and
  • MapperFeature.SORT_CREATOR_PROPERTIES_FIRST for determining how Creator properties are dealt with.

Former (SORT_PROPERTIES_ALPHABETICALLY) will ONLY have effect if latter (SORT_CREATOR_PROPERTIES_FIRST) is false. If SORT_CREATOR_PROPERTIES_FIRST is true, Creator properties are always sorted before any other properties, in declaration order.

NOTE: above is only for handling in absence of explicit ordering by @JsonPropertyOrder.

@cowtowncoder cowtowncoder added to-evaluate Issue that has been received but not yet evaluated 3.x Issues to be only tackled for Jackson 3.x, not 2.x and removed to-evaluate Issue that has been received but not yet evaluated labels Jun 19, 2024
@cowtowncoder
Copy link
Member Author

@pjfanning Above is meant to basically change defaults to sane(r): Record/Case/Data Creator props in declaration order first; then alphabetic (lexicographic) for the rest. And with just 2 MapperFeatures.
Can still be improved upon but seems like an ok first step.

cowtowncoder added a commit that referenced this issue Jun 19, 2024
@JooHyukKim
Copy link
Member

JooHyukKim commented Jun 19, 2024

Much cleaner now. 👍🏼
Sorry I haven't managed to make time to follow thru the discussion/clean up.

cowtowncoder added a commit that referenced this issue Jun 19, 2024
…LARATION_ORDER`, change default sorting logic (#4590)
@cowtowncoder cowtowncoder added this to the 3.0.0 milestone Jun 19, 2024
@cowtowncoder
Copy link
Member Author

@JooHyukKim no problem, I'm very familiar with this part.

@cowtowncoder
Copy link
Member Author

@pjfanning @JooHyukKim It looks like this change did not cause additional breaks for master/3.0 dependencies. It should basically bring default behavior of sorting closer to 2.x (still sorts non-Creator properties lexicographically; but leaves Creator properties in declaration order, preceding other properties [unless @JsonPropertyOrder used, or @JsonProperty(index=...)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues to be only tackled for Jackson 3.x, not 2.x
Projects
None yet
Development

No branches or pull requests

2 participants