'Jackson fails to convert Java pojo to XML
I am trying to serialize a class Pojo to XML with Jackson XML mapper. Here is how the XML looks and i represented with objects, also:
XML
<Class>
<ClassStudent Type="20">
<Student Age="2" Id="2">5.18</Student>
<Student Age="1" Id="1">4.863</Student>
</ClassStudent>
<ClassStudent Type="226">
<Student Age="3" Id="6" SpecialExpression="Good">1.91</Student>
<Student Age="1" Id="7" SpecialExpression="Prospective">1.89</Student>
</ClassStudent>
</Class>
OBJECT
public class Class{
@JsonProperty("ClassStudent")
private List<ClassStudent> classStudents;
}
public class ClassStudent{
@JsonProperty("Type")
private String type;
@JsonProperty("Student")
private List<Student> student;
}
public class Student{
@JsonProperty("Age")
private String age;
@JsonProperty("Id")
private String id;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("SpecialExpression")
private String specialExpression;
private Double evaluation;
}
I get an unrecognized field on Student level, not recognized field "Age"....
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
