You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that attributes in a POJO must be included first in the @JsonPropertyOrder annotation list in order for the other properties to be ordered.
It is my understanding that the properties in the ordered list take precedence while unlisted properties will follow the ordered properties in any order.
I am using version 2.3.1 from maven central.
In the test class
public class OrderTest
{
private String a = "first";
@JacksonXmlProperty(isAttribute = true)
private String b = "attribute";
private String c = "second";
public static void main(String[] args)
throws Exception
{
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
xmlMapper.writeValue(System.out, new OrderTest());
}
public String getA()
{
return a;
}
public String getB()
{
return b;
}
public String getC()
{
return c;
}
}
annotating the class with either @JsonPropertyOrder({"a", "c"}) or @JsonPropertyOrder({"a", "c", "b"}) results in orderless output while the annotation @JsonPropertyOrder({"b","a", "c"}) orders properly.
The text was updated successfully, but these errors were encountered:
I've noticed that attributes in a POJO must be included first in the
@JsonPropertyOrder
annotation list in order for the other properties to be ordered.It is my understanding that the properties in the ordered list take precedence while unlisted properties will follow the ordered properties in any order.
I am using version 2.3.1 from maven central.
In the test class
annotating the class with either
@JsonPropertyOrder({"a", "c"})
or@JsonPropertyOrder({"a", "c", "b"})
results in orderless output while the annotation@JsonPropertyOrder({"b","a", "c"})
orders properly.The text was updated successfully, but these errors were encountered: