[英]How to disable Serialization in play framework?
我正在使用Play Framework
和morphia
来部署REST
服务。 我像Jackson
响应那样传递通用Object
时遇到以下错误
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class java.lang.Object and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: common.ResponseStatusEntity["data"]->entities.Trainer["appointmentNotificaiton"]->entities.notificaitons.AppointmentNotificaiton["data"])
如何在播放框架中禁用序列化程序验证?
问题是Object
没有任何属性,而Jackson
默认情况下不接受它。 要禁用它,您需要配置ObjectMapper
如下所示:
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
但是更好的方法是返回某种SUCCESS
对象,该对象明确告诉一切OK
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.