When converting json string to object using ObjectMapper I want to validate that it should only convert it to Object only when all the json keys match with that of Class. Eg:
Class ABC{
private String mem1;
private String mem2;
private String mem3;
}
lets say the json string is
{
mem1:'somevalue',
mem3:'somevalue'
}
when using object mapper to convert above json string to class ABC it will convert as it matches mem1 and mem3, I want to validate such that it converts if the json string has all the three members as that of class ABC.
Any idea on how to do it? The only way I can think of is converting json string into JSONObject and then match the keys with the field name of the class