Reputation: 207
The Java object has to be serialized into a json string in the servlet filter for a jersey application.
Have the following object,
@XmlRootElement
@JsonIgnoreProperties({"bar"})
public class Foo{
String a="1";
String b="2";
@JsonIgnore
String bar="3";
};
ObjectMapper om = new ObjectMapper();
om.writeValueAsString(fooObject);
returns,
{
a:"1",
b:"2",
bar:"3" // Inspite of Jsonignore and jsonignoreproperties bar is returned
}
How do I overcome this?
Upvotes: 0
Views: 2271
Reputation: 207
Fixing the imports to fasterxml from codehaus and adding the following feature to the mapper fixed the issue.
mapper.configure(MapperFeature.USE_ANNOTATIONS, true);
Upvotes: 1