Jackson - suppressing serialization(write) of properties dynamically
Posted
by kapil.israni
on Stack Overflow
See other posts from Stack Overflow
or by kapil.israni
Published on 2010-06-05T17:36:38Z
Indexed on
2010/06/05
17:42 UTC
Read the original article
Hit count: 374
I am trying to convert java object to JSON object in Tomcat/jersey using Jackson. And want to suppress serialization(write) of certain properties dynamically.
I can use JsonIgnore, but I want to make the ignore decision at runtime. Any ideas??
So as an example below, I want to suppress "id" field when i serialize the User object to JSON..
new ObjectMapper.writeValueAsString(user);
class User {
private String id = null;
private String firstName = null;
private String lastName = null;
//getters
//setters
}//end class
© Stack Overflow or respective owner