I have the following classes -
Employee
public class Employee {
private String firstName ;
private String lastName ;
private String emailAddress ;
private String ssn ;
}
Payroll
public class Payroll {
// different payroll related fields
private Employee emp ;
}
HR
public class HR {
// different HR related fields
private Employee emp ;
}
Now when I serialize my Payroll class, I don't want to serialize my ssn field from Employee class.
Where as when I serialize my HR class, I don't want to serialize my emailAddress field from Employee class.
How I can dynamically exclude fields from serializing by using Jackson JSON API?