I am using @XmlTransient for hiding some Strings in output XML file. It works fine while marshalling and the XML is fine.
However when I unmarshall the XML, the @XmlTransient marked values appear as null.
I am using @XmlTransient for hiding some Strings in output XML file. It works
Share
What
@XmlTransientDoes@XmlTransientmarks the property as unmapped so it is excluded from both marshalling and unmarshalling.What You Could Do
If you just want to exclude the value from marshalling you may consider using an
XmlAdapterXmlAdapter (StringAdapter)
The
XmlAdapterwill always return""for the marshal operation and the JAXB implementation will return an empty element. If you are using EclipseLink MOXy as your JAXB implementation you could return null to eliminate the node completely (see: http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html).Person
input.xml
Demo
Output