I try to deserialize object that contains null-properties and have the JsonMappingException.
What I do:
String actual =
I also faced the same issue.
I just included a default constructor in the model class along with the other constructor with parameters.
It worked.
package objmodel;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
public class CarModel {
private String company;
private String model;
private String color;
private String power;
public CarModel() {
}
public CarModel(String company, String model, String color, String power) {
this.company = company;
this.model = model;
this.color = color;
this.power = power;
}
@JsonDeserialize
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
@JsonDeserialize
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
@JsonDeserialize
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@JsonDeserialize
public String getPower() {
return power;
}
public void setPower(String power) {
this.power = power;
}
}