Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to Add @JsonIgnore property on Password in response Json

I want to add @JsonIgnore of Jackson On the Password property of User domain such that I must be able to send the Json With password and It saves my data in Database but in response I don't want to show the password.

How can I acheive this please help me.

I tried to use it at the Domain level of the User where the properties are defined but it Totally Ignore the property in the getter and setter methods.

I have tried this

private String password;
 @JsonIgnore
        public String getPassword() {
            return this.password;
        } 
like image 668
CandleCoder Avatar asked Aug 26 '15 06:08

CandleCoder


1 Answers

You can do it this way too if you don't want to manually create the getters/setters (eg. when using lombok's @Data)

@JsonProperty(access = Access.WRITE_ONLY)
private String password;
like image 111
Selindek Avatar answered Oct 24 '22 23:10

Selindek