Skip to content

Can not find an option to exclude a field before applying patch #121

Open
@rajeshhereforyou

Description

@rajeshhereforyou

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions