Is there a way to use annotation on a List property in a class to use ACCEPT_SINGLE_VALUE_AS_ARRAY
in Jackson
? I\'m using Spring and getting the b
You can use @JsonFormat annotation,
public class MyClass {
@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
private List value;
}
To work with this you need to have Jackson version min 2.7.0
. You can also use other available JsonFormat Features
@Autowired private ObjectMapper mapper;
//...
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
Initializer Class
.Jackson
in your Bean Configuration
These would solve the issue but it will be activated for every deserialization
process.