Skip to content

Make @JsonbTypeInfo.key aware upon deserilisation #2241

@gdevxy

Description

@gdevxy

Hello,

JsonObjectReader.java

explicitly assumes "__typename" as the subtype field.

Would it be possible to consider @JsonbTypeInfo(key = "myField") key field if the annotation is defined?

There are use cases where the type is not part of the schema (e.g JSON scalar) and demands more flexibility.

Considering Contentful JSON scalar model for rich-text the expected supported code could be:

@JsonbTypeInfo(key = "nodeType", value = {
	@JsonbSubtype(alias = "document", type = Document.class),
	@JsonbSubtype(alias = "heading-1", type = Heading1.class)
	...
})
public interface Content {

}
@Type("document")
public class Document implements Content {

}

Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions