更新时间:2023-02-19 07:40:39
几个选项;首先,您要启用ACCEPT_EMPTY_STRING_AS_NULL_OBJECT":
Couple of options; first, you want to enable `ACCEPT_EMPTY_STRING_AS_NULL_OBJECT':
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
使空字符串变为空.如果您希望将其转换为实际的空列表,请覆盖 setter:
so that empty String becomes null. And if you want it to get converted to actual empty List, override setter:
public void setChildren(List<Child> c) {
if (c == null) {
children = Collections.emptyList();
} else {
chidlren = c;
}
}