I am having a POJO UserRequest.java which has 4 fields in it and my use case is that I need to send this POJO as request object with 3 fields to REST Endpoint-1 and as another request object with 4 fields to REST Endpoint-2 (as this one needs 4 fields as input).
public class UserRequest(){
private String field1;
private String field2;
private String field3;
private String field4;
}
So I want to use same POJO for both REST Endpoints with 'field4' to be passed only in 2nd Endpoint. I tried using @JSONIgnore annotation over 'field4' but it sends 'field4' as null in 1st Endpoint but 1st Endpoint fails as it does not want 'field4' at all. Please suggest how can I use same POJO for both Endpoints.