Jakarta JSON Binding (JSON-B) adapters for the types defined in Core.
Simply add an @JsonbTypeAdapter to your field:
public class Data {
@JsonbProperty
@JsonbTypeAdapter(EmailAddressJsonbAdapter.class)
public EmailAddress email;
}
You can also use the JsonbUtils.getJsonbAdapters() method to add all adapters to the JsonbConfig:
public static <T> String toJson(final T obj) {
final JsonbConfig config = new JsonbConfig().withAdapters(JsonbUtils.getJsonbAdapterArray());
final Jsonb jsonb = JsonbBuilder.create(config);
return jsonb.toJson(obj, obj.getClass());
}