I'm getting a JSON response in a RESTful endpoint. The fields in the response are variable. In particular some fields that I do not care about them. Because of some requirements I have to use JSR 303 validation annotation to an envelope class to handle the response.
The body of the response is like:
{
"parameter1":"val1",
"parameter2":"val2",
"optional_parameter":"valopt",
"not_important_list":["v1","v2","v3"]
}
My class is like:
public class MessageEnvelope {
@NotNull
@NotBlank
public final String parameter1;
@NotNull
@NotBlank
public final String parameter2;
//the rest of the fields should be ignored
}
I receive mapping error because of the the extra fields. How can I ignore the extra fields that I do not care about them?