Hi there,

I'm trying to use @JsonAppend to programmatically add a field to a POJO 
during serialization.

I have :

   interface Targetable
   class Action implements Targetable

I'm trying to have @JsonAppend(props = {@JsonAppend.Prop(name = "target", 
value = TargetWriter.class, type = URI.class)}) applied to all classes that 
implements Targetable.

The first thing I tried was simply to add @JsonAppend to my Targetable 
interface, but this looks to have no effect when serializing an Action:

    @JsonAppend(
        props = {
                @JsonAppend.Prop(name = "target", value = 
TargetWriter.class, type = URI.class)
        })
    public interface Targetable {
    }


Then I tried to use a mix-in class and to apply it to Targetable:

    @JsonAppend(
            props = {
                    @JsonAppend.Prop(name = "target", value = 
TargetWriter.class, type = URI.class)
            })
    public static class TargetMixin {}

   MAPPER.addMixIn(Targetable.class, TargetMixin.class);

Still no luck. So the last thing I tried is to apply TargetMixin to Action 
directly:

   MAPPER.addMixIn(Action.class, TargetMixin.class);

And this is working.

My question is: is it possible to apply @JsonAppend to an interface, 
without having to list all of its implementations, and ideally without 
mix-in (ie. like the first example in my post)?

Thanks a lot!
Clément

-- 
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 post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to