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

Use @JsonProperty(index) for sorting properties on serialization #2555

Closed
cowtowncoder opened this issue Nov 28, 2019 · 0 comments
Closed

Use @JsonProperty(index) for sorting properties on serialization #2555

cowtowncoder opened this issue Nov 28, 2019 · 0 comments

Comments

@cowtowncoder
Copy link
Member

Although property index was added in Jackson 2.4, and is used for some purposes (such as integer field id for protobuf), it is not yet (as of 2.10) used for ordering properties in other contexts. But it probably should be: there are already requests to use it for CSV headers, for example, and it seems reasonable that ordering would be based on combination of things so that:

  1. Explicit ordering (via @JsonPropertyOrder) would have highest priority
  2. @JsonProperty.index should be used after this
  3. Possible alphabetic ordering for things not covered by (1) or (2)

It may become necessary to allow NOT doing this, too (via MapperFeature), but let's start by assumption that index should be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant