在springboot反序列化器中包含带jackson的root对象 [英] Include root object with jackson in springboot deserializer
本文介绍了在springboot反序列化器中包含带jackson的root对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在我的jackson反序列化程序中使用spring-boot包含objeto root?
How can I include the objeto root in my jackson deserializer with spring-boot?
我尝试输入application.properties
i try to put in application.properties
spring.jackson.deserialization.UNWRAP_ROOT_VALUE=true
我尝试使用一个配置器
@Configuration
public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.featuresToEnable(DeserializationFeature.UNWRAP_ROOT_VALUE);
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"));
builder.indentOutput(true);
return builder;
}
}
我放入了我的classe注释
And i put in my classe the annotation
@JsonRootName("contato")
public class TbContato extends EntityBase {
但是没有工作我得到了这个回报:
but dont work i got this return:
{
"cdContato": 12,
"dtContato": "03/08/2015 16:04:43",
"cdUsuario": null,
"nmParte": "Fabio Ebner",
"nmEmailParte": "fabioebner@gmail.com",
"nmAssunto": "Assuntttoooo",
"dsMensagem": "mensagem nessa porra aqui",
"dtResposta": null,
"dsResposta": null,
"cdUsuarioResposta": null,
"nmUsuarioResposta": null
}
没有根。
推荐答案
那是因为你序列化没有反序列化。尝试使用
That's because you're serializing not deserializing. Try using
spring.jackson.serialization.WRAP_ROOT_VALUE=true
这篇关于在springboot反序列化器中包含带jackson的root对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文