Hi I am sending a JSON Post request using the FireFox RestClient.
My JSON Request is as below:
{ "firstName": "Test", "lastName": "1", "isActive": 1 }
My POJO has isActive field as below
private boolean isActive;
My Controller is define as below
@RequestMapping(method = {RequestMethod.POST,
RequestMethod.PUT}, value = "/save")
public ResponseEntity<RestResponse> save(
@RequestBody POJOUserDetails userDetails, WebRequest request){
In my POJO, when I check the value of isActive, it is false no matter what I send. I tried below value in my JSON request
"isActive": 1
"isActive": true
"isActive": "true"
"isActive": ""
"isActive": null
"isActive": false
All of above sends false in my controller. Please help. Thanks
Adding POJO details
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include=Inclusion.NON_EMPTY)
public class POJOUserDetails {
private String firstName;
private String lastName;
private boolean isActive;
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}