Replies: 2 comments 2 replies
|
What exactly are you doing? What is the input, what kind of type is You are missing a lot of relevant information here to try to help. |
|
The public class Item {
private String name;
private List<String> tags;
@JsonSetter(nulls = Nulls.AS_EMPTY)
public void setTags(List<String> tags) {
this.tags = tags != null ? tags : Collections.emptyList();
}
}For this to work, the setter must already handle the empty case. The If you want globally empty collections for null fields, configure the ObjectMapper: ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));Note: |
Uh oh!
There was an error while loading. Please reload this page.
@JsonSetter (nulls = Nulls.AS_EMPTY)
becomes ""
How to assign an enumeration
now protocol is null
I want to make "" become an enumeration
@JsonSetter(nulls = Nulls.AS_EMPTY)
private Constants.PROTO_TYPE protocol;
All reactions