Apologies for slow follow-up. I think that usage as List/array element is difficult to implement, and generally I don't think it's something that commonly causes problems. Handling of property values and array elements is quite distinct with current processing so I don't think I'd want to do this.
As to direct serialization... it seems to me that caller should just not call method instead of relying on some sort of filtering. There are practical reasons why additions would be tricky, but in general I haven't seen requests for such additions. -+ Tatu +- On Mon, Jan 30, 2017 at 2:19 PM, Rafał Foltyński <[email protected]> wrote: > Currently @JsonIgnoreType on a type/mixin causes that an object of this type > is not serialized if it's another object's property, e.g.: > > public class Foo { > public Bar bar; > } > > @JsonIgnoreType > public class Bar { > public String a; > } > > and serialized Foo is an empty object "{}" (that's great so far) > > Would it make sense to extend this feature so that Bar is not serialized > when it's a part of an array (or collection)? > Object[] arr = new Object[] {bar}; > mapper.writeValueAsString(arr); > "[]" > > or even when serialized directly? > mapper.writeValueAsString(bar); > "" > > I can easily get this output using custom serializer, but it feels kinda bad > to write custom serializer if you want to ignore the type completely.. > > What do you think? > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
