Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rajeshhereforyou opened this issue Mar 7, 2022 · 0 comments
Open

Comments

@rajeshhereforyou
Copy link

rajeshhereforyou commented Mar 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant