Interface JsonbDeserializer<T>

  • Type Parameters:
    T - Type to bind deserializer for.

    public interface JsonbDeserializer<T>

    Interface representing a custom deserializer for a given type. It provides a low-level API for java object deserialization from JSON stream using JsonParser. Unlike JsonbAdapter, which acts more as converter from one java type to another, deserializer provides more fine grained control over deserialization process.

    DeserializationContext acts as JSONB runtime, able to deserialize any java object provided.

    Sample of custom Deserializer:

         class Box {
             public BoxInner boxInnerObject;
             public String name;
         BoxDeserializer implements JsonbDeserializer<Box> {
             public Box deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
                 Box = new Box();
                 while (parser.hasNext()) {
                     Event event =;
                     if (event == JsonParser.Event.KEY_NAME && parser.getString().equals("boxInnerObject") {
                         // Deserialize inner object
                         box.boxInnerObject = ctx.deserialize(BoxInner.class, jsonParser);
                     } else if (event == JsonParser.Event.KEY_NAME && parser.getString().equals("name") {
                         // Deserialize name property
               ; // move to VALUE
                = parser.getString();
                 return box;

    Deserializers are registered using JsonbConfig.withDeserializers(JsonbDeserializer[]) method or using JsonbTypeDeserializer annotation on type.

    JSON Binding 1.0
    See Also:
    JsonbConfig, JsonbTypeDeserializer, JsonbSerializer, JsonbAdapter
    • Method Detail

      • deserialize

        T deserialize​( parser,
                      DeserializationContext ctx,
                      Type rtType)
        Deserialize JSON stream into object.
        parser - Json parser.
        ctx - Deserialization context.
        rtType - Type of returned object.
        Deserialized instance.