jsr367-experts@jsonb-spec.java.net

[jsr367-experts] Polymorphism support

From: Dmitry Kornilov <dmitry.kornilov_at_oracle.com>
Date: Thu, 31 Mar 2016 23:46:28 +0200

Hi,

I see that polymorphism discussion is still on. I am planning to publish a second draft soon so we need to make a decision rather sooner than later.

I see that we have three options:

1. We don’t support polymorphism in this version of the spec. We still can add it later.

2. We add PolymorphicAdapter suggested by Roman to the spec.

3. We create a special annotation @JsonbPolymorphism (or other name) which will enable polymorphic handling of the annotated type. It can accept a list of supported children as a parameter. Empty list means all children.

Sample:

public class Foo {

    @JsonbPolymorphism
    Animal animal;
}

For me the third option looks the most reasonable one. What do you think?

Thanks,
Dmitry