Open
Description
The proposal is to update Jakarta JSON Binding 3.0 section 4.7.1. Adapters
so that an adapter can be registered on the adapted class itself. For example:
@JsonbTypeAdapter(EmailAddressAdapter.class)
public class EmailAddress {
private String value;
public EmailAddress(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
And
public class EmailAddressAdapter implements JsonbAdapter<EmailAddress, String> {
@Override
public String adaptToJson(EmailAddress obj) {
return obj.getValue();
}
@Override
public EmailAddress adaptFromJson(String obj) {
return new EmailAddress(obj);
}
}
For the purposes specification backwards compatibility and the ability to override an adapter, the existing two forms would take precedence. This is consistent with the specification's requirement use of JsonbTypeAdapter on parameters be ignored if it the adapter is defined on a field or in the config.
Metadata
Metadata
Assignees
Labels
No labels