Skip to content

Order matters? #392

Closed Answered by CarstenWickner
lawrencegrass asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @lawrencegrass,

Fortunately, this had been raised before in #92, i.e., yes: this is possible.

If your compiler happens to honour the declaration order, then you can disable the property sorting with this:

configBuilder.forTypesInGeneral()
        .withPropertySorter((_prop1, _prop2) -> 0);

The standard sorting logic is defined in the PropertySortUtils class, in case you want to apply some other sorting behaviour.

Additionally, the JacksonModule supports to sort an object's properties according to its @JsonPropertyOrder annotation, if the JacksonOption.RESPECT_JSONPROPERTY_ORDER was provided

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lawrencegrass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants