Np. I'd actually miss your follow-up as I didn't get notified by Google..

BUT, I was browsing Github issues and found a related one:
https://github.com/FasterXML/jackson-databind/issues/1060

and I thought that broader scope of @JsonIgnoreType might do the trick.

As to direct serialization... it seems to me that caller should just 
> not call method instead of relying on some sort of filtering. 


It's true for 
Collection<Bar>
but it actually might become handy for
Collection<Object>
and
Object[]

Do you have any ideas for the exclusion described in 1060? I'd gladly 
create a PR as currently I have to filter the objects by "not calling the 
method" :)


W dniu środa, 22 marca 2017 23:25:50 UTC+1 użytkownik Tatu Saloranta 
napisał:
>
> 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] 
> <javascript:>> 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] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > 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.

Reply via email to