@XmlTransient not working for JAX-RS JSON responses in RESTEasy
Issue
- I am using JBoss EAP 6.3 straight out of the box. In other words, I have not tweaked or modified it except for adding datasources.
- I have a POJO class with some fields annotated with
@XmlTransient. This annotation is being ignored. - This problem happens only when a JAX-RS method is annotated with
@Produces("application/json"); it does not happen for a method with@Produces("application/xml"), i.e.@XmlTransientjust work as expected for XML responses. - For instance, with the following POJO class:
private String ignored;
@XmlTransient
public String getIgnored() { return ignored; }
- For
"application/xml"I get:
<return>
<message>
<content>Goodbye, RESTEasy!</content>
</message>
</return>
- But for
"application/json"I get:
{
"message" : {
"content" : "Hello, RESTEasy!",
"ignored" : "Ignore me!!!"
}
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
