In the below code, I am expecting the attributes in the order of properties defined, but not able to get it. The order is always mixed up.
Parent Tag
@JacksonXmlRootElement
public class ParentSpec{
@JacksonXmlProperty(localName = "parentSpec")
@JacksonXmlElementWrapper
public MySpec mySpec;
}
ChildTag
public class MySpec {
@JacksonXmlProperty(localName = "mySpec")
@JacksonXmlElementWrapper(useWrapping = false)
public List<MyData> myDataList;
}
Error Child
@JsonPropertyOrder({"id", "type", "name", "data"})
public class MyData{
@JacksonXmlProperty(isAttribute = true)
public String id;
@JacksonXmlProperty(isAttribute = true)
public String type;
@JacksonXmlProperty(isAttribute = true)
public String name;
@JacksonXmlProperty(isAttribute = true)
public String data;
//Other Pojo
}
I tried using the @JsonPropertyOrder, but it works only for elements it seems.