I have this simple controller that receives a map as input:
@RequestMapping(value = "/providers", method = RequestMethod.PATCH, headers = "Accept=application/json")
@ResponseBody
@Transactional
public Map<String, Object> updateProvider(@RequestBody Map<String, Object> updates,
UriComponentsBuilder uriComponentsBuilder, final HttpServletRequest request) {
return updates;
}
and I have this property configured in Spring Boot in the application.properties
file:
spring.jackson.default-property-inclusion=non_empty
Then, if I make a PATCH request with following JSON object.
{
"name":"frndo",
"lastname":""
}
The content of result in the RESPONSE is:
{
"name":"frndo"
}
But the content of input in the REQUEST is:
{
"name":"frndo",
"lastname":""
}
My question is, Why the content in the REQUEST is different in the RESPONSE if to serialize the Map object you have a global configuration like:
spring.jackson.default-property-inclusion=non_empty
Precisely why when @RequestBody Map<String, Object> updates
arrives have the name
and lastname
fields if lastname
is empty?.
In the RESPONSE you can see the effect of the configuration but in the REQUEST is not seen. What is the explanation of this, if the mapper had to convert the JSON to a java object, and in that process the global configuration had to be applied?
I expected to have the same content in the REQUEST and the RESPONSE
Many thanks!