[英]Empty list in case of absense in request - SpringBoot and Jackson
I have the following class: 我有以下课程:
class A {
List <Integer> l;
int a;
}
Now, when user sends request: 现在,当用户发送请求时:
{
a: 11,
}
it deserializes to Aa=11, Al=null
. 它反序列化为
Aa=11, Al=null
。
I would like to in case of null
send list it deserializes to empty list. 我想在的情况下,
null
发送列表它反序列化到空列表。
Can I do it in some elegant way ? 我可以用优雅的方式做吗?
Just need add default value in l property 只需要在l属性中添加默认值
class A {
List <Integer> l = = new ArrayList<>();
int a;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.