-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
@JsonIgnoreProperties(value = { "password" }, ignoreUnknown = true, allowSetters = true)
public class JsonTest {
private String username;
private String password;
public JsonTest() {
super();
// TODO Auto-generated constructor stub
}
public JsonTest(String username, String password) {
super();
this.username = username;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public static void main(String[] args) {
ObjectMapper mapper = new ObjectMapper();
JsonTest json = new JsonTest("user", "password");
try {
System.out.println(mapper.writeValueAsString(json));
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String jsonString = "{ \"username\":\"username\",\"password\":\"password\" }";
try {
json = mapper.readValue(jsonString, JsonTest.class);
System.out.println(json.getPassword());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
the version is 2.8.7.
the password cannot deserialize.
the output is:
{"username":"user"}
null
Metadata
Metadata
Assignees
Labels
No labels