Skip to content

How to maintain order while using @JsonAnyGetter #196

Answered by cowtowncoder
ManiSingal asked this question in Q&A
Discussion options

You must be logged in to vote

Correct, @JsonAnyGetter contents are not considered "true" properties (plus they are fully dynamic, not known a priori) so none of the ordering-annotations work with it.

Plus, as you have noticed, only one can be specified for a given POJO.

I cannot think of a way to achieve ordering currently, although issues requesting solving issues you outline have existed for a while:

  • #171 (@JsonUnwrapped for Maps) -- but I will actually fix this now due to @JsonAnyGetter providing functionality.
  • #518 (for ordering @JsonAnyGetter with @JsonPropertyOrder)

The problem in solving these is the dynamic nature of "any properties" vs static nature of regular POJO properties, and sorting used.

One way forw…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@JooHyukKim
Comment options

Comment options

You must be logged in to vote
2 replies
@ManiSingal
Comment options

@cowtowncoder
Comment options

Answer selected by ManiSingal
Comment options

You must be logged in to vote
1 reply
@JooHyukKim
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants