java - Spring RESTFUL web Service how to handle inorder to remove null objects in json response -
i have spring webservice returns json response using spring.
the format json returned in is:
{"data": { "bidprice": 26.8, "fundnames": null, "offerprice": 27.4, "fundid": "123456789", "funddescription": "high risk equity fund", "lastupdated": "2015-08-25t15:48:57" }}
i want remove null objects(fundnames) returned response looks like
{"data": { "bidprice": 26.8, "offerprice": 27.4, "fundid": "123456789", "funddescription": "high risk equity fund", "lastupdated": "2015-08-25t15:48:57" }}
my beans.xml
<?xml version="1.0" encoding="utf-8"?> <mvc:annotation-driven/> <context:component-scan base-package="com.blog" /> <bean class="org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping" /> <bean class="org.springframework.web.servlet.view.json.mappingjacksonjsonview"> <property name="contenttype" value="application/json"/> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <property name="messageconverters"> <util:list id="beanlist"> <ref bean="jsonmessageconverter"/> </util:list> </property> </bean> <bean id="jsonmessageconverter" class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter"/>
i'm using xsd generate java class cannot use @jsonserialize(include=jsonserialize.inclusion.non_null) in pojo java class, please advise on how set non_null in spring.xml above config
any appreciated
thanks
Comments
Post a Comment