Skip to content

Latest commit

 

History

History

jsonb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

objects4j-jsonb

Jakarta JSON Binding (JSON-B) adapters for the types defined in Core.

Getting started

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