Instead of using @XmlElementWrapper
you will need to create two classes: SignaturePolicies
and ValidationPolicies
and work them into your domain model. Each of these will have the count
property you wish to add and their corresponding collection (which they replaced on the Statistique
class.
Add attribute to a node java XML Serialization
-
04-10-2022 - |
Domanda
I have an object I'm serializing with annotations:
@Component
@XmlRootElement(name="Stats")
@XmlAccessorType(XmlAccessType.FIELD)
public class Statistique
{
@XmlElement(name="TotalUsers")
private int nbUserTotal;
@XmlElementWrapper(name="UtilisateursParAppli")
@XmlElement(name="Application")
private List<Application> nbUserByAppli;
@XmlElementWrapper(name="SignaturePolicies")
@XmlElement(name="SignaturePolicy")
private List<String> signaturePolicies;
@XmlElementWrapper(name="ValidationPolicies")
@XmlElement(name="ValidationPolicy")
private List<String> validationPolicies;
....
}
I want to add an attribute "count" on SignaturePolicies and ValidationPolicies node. Is it possible to achieve that with XML Annotations?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow