I have a simple User class:
public class User {
private long id;
private String username;
private String password;
private String someCommonData;
private String someAdminData;
}
I would like to have different representations of that User in json. A version for normal users:
{"username":"myName", "someCommonData":"bla"}
and a representation for adminUsers:
{"id":1, "username":"myName", "someCommonData":"bla", "someAdminData":"don't show this to the user!"}
When I use @JsonIgnore then it is always ignored but I would like to have conditional ignore.
The only solution that would work so far is to have two different classes. Isn't there a more beautiful solution?