On Tue, Mar 26, 2019 at 12:21 AM Suraj Mathai <[email protected]>
wrote:

> Thanks very much.
>
> In that case , is there an alternative for something I am trying to
> achieve
>
> class Trade {
>
>    int id;
>    String trader;
> }
>
> class FX extends Trade {
>
>    double rate;
> }
>
>

> Can my json on FX object have nested fields from a flat object structure.
> ? Is writing a custom serialiser the only way or I can use annotations
> assuming FX is 3rd party and  can't be changed .
>
> {
>    id:123
>   trader : "Sam"
>   product {
>      rate : 0.34
>   }
>
> }
>
>
Using annotations on 3rd party libraries is relatively easy, using Mix-In
Annotation (see f.ex https://dzone.com/articles/jackson-mixin-to-the-rescue
).

If I understand your example correctly, no annotation would quite do that
-- the reverse would be possible with `@JsonUnwrapped`, but there is no
matching `@JsonWrapped`.

-+ Tatu +-


> Thanks again
>
> On Tuesday, March 26, 2019 at 1:35:03 PM UTC+11, Tatu Saloranta wrote:
>>
>> On Mon, Mar 25, 2019 at 5:18 PM Suraj Mathai <[email protected]>
>> wrote:
>> >
>> > Hi,
>> >
>> > I have Parent Class and  Subclasses . Can I customize the serialization
>> of fields of parent class using ParentClassSerializer and fields of
>> subclass using SubClassSerializer. how do i do this ?
>> >
>> > Thanks in advance for your time and help
>>
>> If you mean using 2 serializers for one value, no, I don't think there
>> is a way to do that.
>>
>> -+ Tatu +-
>>
> --
> 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.

Reply via email to