On Fri, Dec 1, 2023 at 11:21 PM thom...@gmail.com <thomh...@gmail.com> wrote:
>
> I have an optional tag in my schema. If it is null, I want to not place the 
> tag in the doc. Currently, I get
>
> <seg/>
>
> Which is not terrible, but not necessary.

The quickest way is probably to use annotation `@JsonInclude` on POJO
or property:

@JsonInclude(JsonInclude.Include.NON_NULL)

(see `TestViews.java` test f.ex)

It is also possible change defaults with something like:

    final XmlMapper mapper = XmlMapper.builder()
        .changeDefaultPropertyInclusion(incl ->
incl.withValueInclusion(Include.NON_NULL))
        .build();

I hope this helps,

-+ Tatu +-

> Thanks.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/jackson-user/8c8d03ae-82c6-4eaa-86d8-57ab392eb498n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/CAL4a10g3bvPK6GjbyM-KtbQLFeaaC6W1XJhXfg6PP%2BgM6yfAig%40mail.gmail.com.

Reply via email to