I am using JAXB with annotations. I want the creditcard info to be displayed without the creditcardinfo node being displayed. FYI CreditCardInfo is an object of complex type.
@XmlRootElement
public Class Notification{
private String notifDate;
private CreditCardInfo ccInfo;
}
public Class CreditCardInfo{
private int ccNum;
private String expiryMonth;
}
Desired output
<notification>
<date>04/29/11</date>
<ccNum>3456</ccNum>
<expiry_month>November</expiry_month>
</notification>
Regards,
-Anand
You could use the @XmlPath extension in EclipseLink JAXB (MOXy) to handle this use case. Note: I’m the MOXy lead.
Notification
CreditCardInfo
Demo
jaxb.properties
To use MOXy as your JAXB provider you need to add a file named jaxb.properties in the same package as your model classes with the following entry:
Input/Output
For More Information