Last active
July 28, 2020 08:06
-
-
Save iamvickyav/683d96db6c4d4b4f8fdd08c848b3536e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to ignore fields in Java Object while serializing | |
// Approach 1 - @JsonIgnoreProperties | |
@JsonIgnoreProperties(value = {"id", "dob"}) | |
public class User { | |
private Integer id; | |
private String name; | |
private Date dob; | |
private String city; | |
// constructors, getters & setters are ignored | |
} | |
// Approach 2 - @JsonIgnore | |
public class User { | |
@JsonIgnore | |
private Integer id; | |
private String name; | |
@JsonIgnore | |
private Date dob; | |
private String city; | |
// constructors, getters & setters are ignored | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment