Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make @JsonbTypeInfo.key aware upon deserilisation #2241

Open
gdevxy opened this issue Dec 15, 2024 · 0 comments
Open

Make @JsonbTypeInfo.key aware upon deserilisation #2241

gdevxy opened this issue Dec 15, 2024 · 0 comments

Comments

@gdevxy
Copy link

gdevxy commented Dec 15, 2024

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant