@JsonIncludeProperties and @JsonPropertyOrder could be combined
See original GitHub issueI was experimenting a bit with the @JsonIncludeProperties
introduced recently.
It would be nice if it would automatically apply the property order instead of having to include @JsonPropertyOrder
as well.
Now we need:
@JsonIncludeProperties({
"id",
"code",
"name"
})
@JsonPropertyOrder({
"id",
"code",
"name"
})
public class Continent {
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Using Jackson annotations with Jackson-jr | by @cowtowncoder
@JsonProperty for basic inclusion, renaming; @JsonPropertyOrder for defining specific order of properties when writing; @JsonIgnore / @ ...
Read more >Using @JsonInclude to define properties inclusion rules
@JsonInclude annotation can be used to indicate when the annotated property can be serialized. Normally property values are always included, ...
Read more >Jackson Annotation Examples - Baeldung
We can use the @JsonPropertyOrder annotation to specify the order of properties on ... Then here's how it all ties in together:
Read more >Package com.fasterxml.jackson.annotation - Javadoc.io
Annotation used to define a human-readable description for a logical property. JsonPropertyOrder. Annotation that can be used to define ordering (possibly ...
Read more >Jackson @JsonPropertyOrder is ignored - Stack Overflow
Can anybody help me with that? Also, I tried this using Jackson version 2.6.3 and 2.3.5. Both works the same way. java ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmmh. Interesting idea, I like it.
Will have to think about how this should be achieved, semantics probably cannot be changed by automatically using it (unless this would have the lowest priority? Or maybe not even then). But adding a new
OptBoolean
property (order
?) could work, allow easy opt-in.Yes you are of course right it is
@JsonPropertyOrder
. So maybe something like below then:I think indeed
order
is sufficient 😉