How to configure Json-B in RestEasy Client?

245 Views Asked by At

I use the RestEasy client. In the processed json object there is a base64 encoded byte array. However, the Yasson library assumes an int-coded array in the unconfigured case. How I tell the JsonConfig the BinaryDataStrategy.BASE_64?

I have tried with no luck with

@Provider
@Priority(99)
@Produces({MediaType.APPLICATION_JSON})
public class JSONConfigurator implements ContextResolver<Jsonb> {

    @Override
    public Jsonb getContext(Class type) {
        JsonbConfig config = new JsonbConfig()
                .withBinaryDataStrategy(BinaryDataStrategy.BASE_64);
        return JsonbBuilder.newBuilder()
                .withConfig(config)
                .build();
    }
}

How does this work? How to configure Json-B in RestEasy Client?

1

There are 1 best solutions below

0
Superhugo On

I need to register my CustomResolver<Jsonb> on my ReastEasy-Client as follows:

ResteasyClient client = clientBuilder.build();
client.register(JSONConfigurator.class);