My flow is given below.
Input json request has some fields set to "". I want the response json to have those fields set to "" as well. Instead, the fields are assigned values null or 0.
What I need: How do I set the fields in response to "" instead of null or 0?
Code:
JSON Request:
    {
    userID: "ABC",
    creationDate: "",
    noOfItems: "" 
}
Bean Definition:
class UserOrderDetails {
    private String userID;
    private LocalDate creationDate;
    private int noOfItems;
    public String getUserID() {
        return this.userID;
    }
    public void setUserID(String userID) {
        this.userID=userID;
    }
    public LocalDate getCreationDate() {
        return this.creationDate;
    }
    public void setCreationDate(LocalDate creationDate) {
        this.creationDate=userID;
    }   
    public int getNoOfItems() {
        return this.noOfItems;
    }
    public void setNoOfItems(int noOfItems) {
        this.noOfItems=noOfItems;
    }
}
Controller class:
class UserOrderCreationController {
@RequestMapping(value = "/createUserOrder", method = RequestMethod.POST)
    public ResponseEntity<?> createUserOrder(@RequestBody UserOrderDetails userOrderDetails , @RequestHeader HttpHeaders headers) throws Exception{
    //Some business logic to handle the user Order
    return new ResponseEntity<UserOrderDetails>(userOrderDetails, HttpStatus.CREATED);
    }
}
Response:
{
    userID: "ABC",
    creationDate: null,
    noOfItems: 0 
}
NOTE: I cannot change LocalDate, int - data types of CreationDate and noOfItems to String since it is used by many other classes.

 
    