On Fri, Sep 21, 2018 at 11:37 AM Broly1 <bro...@gmail.com> wrote:
>
> Hi all first time using java object to Json conversion.
>
> I'm trying to have the output (Json) not include any null values.
>
> I've tried the following.
>   objectMapper.setSerializationInclusion(Include.NON_NULL);
>   objectMapper.setSerializationInclusion(Include.NON_EMPTY);
>   @JsonInclude(Include.NON_NULL)
>
> However i keep getting an output such as this:
> "Order1" : [ null, null, null, null, null, null ],
> "Order2" : [ null, null, null, null, null, null ],
>
> I know it is partially working because with out the Include.NON_NULL (and 
> NON_EMPTY), there are around 2200 null values.
>
> Anyone know why these are missed?

Output exclusion rules unfortunately only cover contents of POJOs
(that is, field values) and Maps.
For container types (Collections, arrays) only container value itself
may be excluded (if empty, null, wrt settings),
but elements are not checked currently. This was originally as JSON
arrays are positional and removing elements
seems more intrusive (and less likely desired) than excluding JSON
object elements (where `null` would typically
be implied for absent entry).

In theory support for excluding elements could be added but that would
require some API changes to retain
backwards compatibility (that is, it is not possible to just make
existing arrays, Collections, follow value exclusion
since that would be major behavioral change).

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to