question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@JsonIncludeProperties and @JsonPropertyOrder could be combined

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Mar 18, 2021

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.

0reactions
marceloverdijkcommented, Mar 19, 2021

Yes you are of course right it is @JsonPropertyOrder. So maybe something like below then:

@JsonIncludeProperties(order = OptBoolean.TRUE, value = {
        "id",
        "code",
        "name"
})
public class Continent {

}

I think indeed order is sufficient 😉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found