On Thu, Jan 6, 2022 at 10:58 AM Reji Mathews <[email protected]> wrote:
> Hello !
>
> I have a requirement where I need to select the concrete class based on
> presence of a key field in my json
>
> I have a base abstract class Activity.java which is extended by
> CommandActivity.java and ViewActivity.java
>
> Ex -
> =====
> Json 1
>
> {
> "command" : "abc"
> "parameters" : ["ls"]
> "user" : "iamuser1"
> "origin" : "asia"
> }
>
> Json2
>
> {
> "view" : "C001"
> "resource":"XYZ"
> "user" : "iamuser2"
> "origin" : "US"
> }
>
> Based on presence of key command or view, jackson needs to select the
> right concrete class for deserizliation.
>
> Wondering if this feature is available already in the framework? If
> someone had similar problem solved earlier, would be awesome if you can
> share the code snippet
>
This sounds like it might be solvable using Jackson 2.12 added "infer" type:
https://cowtowncoder.medium.com/jackson-2-12-most-wanted-1-5-deduction-based-polymorphism-c7fb51db7818
of polymorphic deserialization?
-+ Tatu +-
> Cheers
> Reji
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/jackson-user/10a1f412-d873-450b-bf48-9bf7abb20a81n%40googlegroups.com
> <https://groups.google.com/d/msgid/jackson-user/10a1f412-d873-450b-bf48-9bf7abb20a81n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/CAGrxA24%2B6eyc8Am7sbkqRP5qFWT-oXrB3KxKYGyXMzTCY09sAg%40mail.gmail.com.