Skip to content
Discussion options

You must be logged in to vote

This is why AI doesn't yet replace library authors. :-D

The thing @indyteo is looking for is, I think, @JsonFormat(shape=JsonFormat.Shape.ARRAY) like so:

@JsonFormat(shape=JsonFormat.Shape.ARRAY)
// Possibly also: @JsonPropertyOrder(alphabetic=true)
class POJO {
   // or: @JsonProperty(index=0)
   public int a;
}

and for more examples see f.ex https://github.com/FasterXML/jackson-databind/blob/3.x/src/test/java/tools/jackson/databind/struct/POJOAsArrayTest.java#L64

NOTE: works particularly well for Records since they define property order by declaration order.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@indyteo
Comment options

@cowtowncoder
Comment options

@indyteo
Comment options

@cowtowncoder
Comment options

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