I have below a REST response which needs to be created in the code:
<sample>
<tags>
<tag>
<name>ABC</name>
<Date>2014-10-14T12:30:05Z</ingress>
</tag>
<tag>
<name>DEF</name>
<Date>2014-10-14T12:30:05Z</ingress>
</tag>
</tags>
</sample>
However,I am getting
<sample>
<tags>
<name>ABC</name>
<Date>2014-10-14T12:30:05Z</ingress>
</tags>
<tags>
<name>DEF</name>
<Date>2014-10-14T12:30:05Z</ingress>
</tags>
</sample>
in the response.Can someone please help me how the declaration of Java class to get the desired REST response ?
Here is the java code:
@XmlRootElement(name = "sample")
public class Sample {
private List<Tag> tags;
@XmlElement(name = "tags")
public List<Tag> getTags() {
return tags;
}
/**
* @param tags
* the tags to set
*/
public void setTags(List<Tag> tags) {
this.tags = tags;
}
}
@XmlRootElement(name = "tag")
public class Tag {
private String name;
private Date date;
/**
* @return the name
*/
@XmlElement(name = "name")
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the date
*/
@XmlElement(name = "date")
public Date getDate() {
return date;
}
/**
* @param date
* the date to set
*/
public void setDate(Date date) {
this.date = date;
}
}
Thanks