On Wed, Aug 7, 2019 at 9:38 AM Pablo Pazos <
pabl...@gmail.com> wrote:
>
> Hi, I have a complex model, where some attributes are collections and if the collection is empty I need to ignore adding if to the serialized JSON object, because right now I see items: [] everywhere (many of my classes have that attribute but it's empty most of the time.
>
> Is there a way to do this in Jackson?
Via annotations you would add
@JsonInclude(include = Include.NON_EMPTY)
but there is also "config override" setting to define default; usage
maybe best seen in
src/test/java/com/fasterxml/jackson/databind/ser/filter/JsonIncludeOverrideTest.java
but you can basically define default inclusion setting for all
properties, or properties of certain type (based on declared property
type)
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...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/e1f875ee-6d36-4a03-89a7-0e8bee7157d4%40googlegroups.com.