Alternatives to @Deprecated SerializationFeature.WRITE_EMPTY_JSON_ARRAYS

The Javadoc is just plain wrong.

  1. "using com.fasterxml.jackson.annotation.JsonFormat": There are plenty of cases where annotations are patently NOT better, most notably when you can't annotate the POJOS because you don't own them, or when you need to override the annototations to get a different behavior than you usually want.

  2. "configuration overrides": That would be great, but to my knowledge there are no other overrides that will take precedence over annotations.

From the user perspective, the only thing bad about the deprecated option is that it is deprecated, and thus might not be supported in the future. That is of course a real concern - you might one day have to choose between a vital security update and keeping your code working without a rewrite.


At the class level, you can use the @JsonInclude like:

@JsonInclude( JsonInclude.Include.NON_EMPTY )
public class MyClass ...

Also, at the mapper level you can do something like:

mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);