Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I ignore a field in json response?

Tags:

java

json

jackson

@Column(name = "password", nullable = false)
@JSonIgnore
private String password;

I have given the above field in my model class, but It did not work for the POST method.

Error:null value in column "password" violates not-null constraint

like image 740
Fida Avatar asked Oct 22 '25 13:10

Fida


1 Answers

Add @JsonIgnore only on getter method.

@Column(name = "password", nullable = false)
private String password;

@JsonIgnore
public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

or

@JsonProperty(access = Access.WRITE_ONLY)
@Column(name = "password", nullable = false)
private String password;
like image 53
Ady Junior Avatar answered Oct 25 '25 03:10

Ady Junior



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!