Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jsonb-dev] Registration of JsonbAdapter on target class

Markus Karg brought this up two years ago and it would be good to revisit this and have a productive discussion.  If someone would like to discuss alternatives to JsonbAdapter, please start another thread.

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;
        }
    }


This is supported by Yasson and partially supported by Johnzon.  See: 

 - https://github.com/jakartaee/jsonb-api/issues/372

As this is clearly supported in practice and getting used in the wild, I do not see a reason not to include it in the spec to ensure greater compatibility between implementations.

If we agree, I propose we let Markus have the honors of contributing the spec text.


Thoughts overall?


-David



Back to the top