Is there a way when using @ResponseBody annotation to have null values mapped to empty strings?
Is there a way when using @ResponseBody annotation to have null values mapped to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will have to write a custom Jackson Serializer – a good example is here – http://wiki.fasterxml.com/JacksonHowToCustomSerializers (there is a specific example of how to convert null values to empty Strings that you can use)
Here are all the steps(for Jackson < 2.0):
Write your custom null Serializer:
Register this with Jackson Objectmapper:
Register this objectmapper with Spring MVC: