On Wed, Aug 7, 2019 at 12:24 PM Pablo Pazos <pablo....@gmail.com> wrote: > > Thanks! how can that annotation be included in a MixIn?
Same was as any annotation, marking either getter/setter of field. Mix-ins work for members as well as class annotations. But configOverride approach may be more convenient, if you want wide defaults. -+ Tatu +- > > On Wednesday, August 7, 2019 at 2:27:35 PM UTC-3, Tatu Saloranta wrote: >> >> 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 jackso...@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. > > -- > 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/052b9d63-64ed-4a51-afa8-479ed1166896%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/CAL4a10ibKCqYQXD8eng5iEe9RqkbfokBC_g%3DdgxjdhuLJVFcVg%40mail.gmail.com.