java - SpringMVC response json not right for Boolean properties -
i use springmvc 4.2.5, , make rest controller, response not want. here it's detail. have entity named propertyentity,
public class propertyentity implements serializable, cloneable { private static final long serialversionuid = -7032855749875735832l; private int id; private string propertyname; private boolean isenable; private boolean isdimension; private boolean ismetric; } and controller is:
@controller @requestmapping("/api/v1/properties") public class propertycontroller { @requestmapping(method = requestmethod.get, produces = "application/json;charset=utf-8") @responsestatus(httpstatus.ok) public @responsebody list<propertyentity> getall() { return propertyservice.getall(); } } when request api, result is:
[ { "id": 1, "propertyname": "money1", "isenable": true, "dimension": false, "metric": true }, { "id": 2, "propertyname": "money2", "isenable": true, "dimension": false, "metric": true } ] what want is:
[ { "id": 1, "propertyname": "money1", "isenable": true, "isdimension": false, "ismetric": true }, { "id": 2, "propertyname": "money2", "isenable": true, "isdimension": false, "ismetric": true } ] the unexpected thing is: isdimention changed dimension, ismetric changed metric, isenable right.
i assume using jackson converting "propertyentity" object json.
a possible problem here getters , setters in propertyentity class.
see getter/setter of isenable , follow similar naming convention ismetric & isdimension
ensure getters of boolean start isismetric()... instead of getismetric().
if not help, please share getters , setters on here.
Comments
Post a Comment