jaxb 解组创建重复的对象列表:如何解组列表中的对象?
xml 文件和代码如下所示,同时解组读取元素获取重复列表我正在使用 jaxb 注释,我的最终输出是重复列表
<data_reading>
<load_survey>
<interval_settings value="30" xunit="mins" />
<measurement name="energy_real" xunit="KWH" />
<reading interval="00" value="000.010" />
<reading interval="01" value="000.000" />
<reading interval="02" value="000.050" />
<reading interval="03" value="000.080" />
<reading interval="04" value="000.010" />
</load_survey>
</data_reading>
These are my classes
@XmlAccessorType(XmlAccessType.FIELD)
public class LoadSurvey {
@XmlElement(name="interval_settings")
private IntervalSettings interval_settings;
@XmlElement(name="measurement")
private Measurement measurement;
@XmlElement(name="reading", type = Reading.class)
private List<Reading> readings;
//setter and getters
}
@XmlRootElement(name="data_reading")
@XmlAccessorType(XmlAccessType.FIELD)
public class DataReading {
@XmlElement(name="load_survey")
private LoadSurvey load_survey;
}
This is my code Here i am getting following output
[data_reading [load_survey=LoadSurvey [interval_settings=IntervalSettings [value=30, xunit=mins], measurement=Measurement [name=energy_real, xunit=KWH], readings=[Reading [interval=00, value=0.23], Reading [interval=01, value=0.23], Reading [interval=02, value=0.22], Reading [interval=03, value=0.21], Reading [interval=04, value=0.23], Reading [interval=05, value=0.24], Reading [interval=00, value=0.23], Reading [interval=01, value=0.23], Reading [interval=02, value=0.22], Reading [interval=03, value=0.21], Reading [interval=04, value=0.23], Reading [interval=05, value=0.24]]]]
Getting Readings list duplicates with jaxb please provide any solution