How can I turn this XML:
<units>
<unit name="maths-101" points="120"/>
<unit name="english-101" points="60"/>
</units>
<students>
<student>
<unit name="maths-101"/>
<unit name="english-101"/>
</student>
<student>
<unit name="english-101"/>
</student>
</students>
into something like this Java:
class Student {
private List<Unit> units;
public List<Unit> getUnits() {
return units;
}
public void setUnits(final List<Unit> units) {
this.units = units;
}
}
class Unit {
private String name;
private Integer points;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public Integer getPoints() {
return points;
}
public void setPoints(final Integer points) {
this.points = points;
}
}
After deserializing, I want to be able to retrieve the points for a Unit,
directly from a student (e.g. student.getUnit().getPoints()) and do not
want to have to look up the unit by name from a separate list of units.
I have tried the solution suggested in this StackOverflow Answer
<https://stackoverflow.com/a/41082832/236587> but I get an error saying
"Already had POJO for id (java.lang.String) [[ObjectId: key=foo,
type=com.fasterxml.jackson.databind.deser.impl.PropertyBasedObjectIdGenerator,
scope=Unit]]. I'm not sure if that only works for JSON or if I need a
slightly different XML/Java structure to get this working?
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.