Currently, I'm creating REST Service with Spring.
My request handler in @RestController:
@RequestMapping(value = "employees/", method = RequestMethod.POST)
public Response setEmployees(@RequestBody Employee employee) {
Response response = employeeManager.setEmployee(employee);
return response;
}
Employee has fields like: login,tabNumber,firstName etc.
The real problem is that my REST service customers want to send request with
another field names, that does not corresponds to Java naming conventions. Like TABNUMBER, UNITS_NAME etc. Jackson API converts JSON data to Java object corresponding to it field names... How to solve it? How can I bind custom JSON field names to my Java object field names?
You can use JsonProperty annotation as below so your clients can send request field name as FIRST_NAME and it can mapped to Employee class :