Can not find an option to exclude a field before applying patch
Opened this issue · 0 comments
Hi,
I've a simple model called user with some fields with getters and setters. Now, I had to implement an interface and had to implement a method ( a getter method).
public class User implements MyInterface{
private String field1;
private String field2;
// Getters and setters for field1 and field2
//Here I'm implementing the abstract method from the interface as shown here
public String getUserName(){
return "my name";
}
}
public interface MyInterface{
public String getUserName();
}
Now, I'm trying to apply patch to replace 'field1' in the Uses POJO as shown below
JsonNode jsonNode = objectMapper.convertValue(user, JsonNode.class);
JsonNode jsonNodeAfterPatch = jsonPatch.apply(jsonNode);
and getting an exception as shown below
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "userName"
With that said, as far as i know, the reason behind this issue could be there is no field called 'userName' in the POJO. If my understanding is correct, I don't see any option to exclude this field when i'm trying apply the patch for a different field.
Please suggest.