Copy <dependency>
<groupId>com.github.ljtfreitas</groupId>
<artifactId>java-restify-json-jsonb-converter</artifactId>
<version>{version}</version>
</dependency>
Copy dependencies {
compile("com.github.ljtfreitas:java-restify-json-jsonb-converter:{version}")
}
Copy public interface MyApi {
/* requisições e respostas com o content-type application/json
serão automaticamente serializadas/deserializadas usando o json-b */
@Path("/customers") @Post
@JsonContent
Customer createCustomer(@BodyParameter Customer customer);
@Path("/customers/{id}") @Get
Customer findCustomer(@PathParameter String id);
}
Copy import com.github.ljtfreitas.restify.http.client.message.converter.json.JsonBMessageConverter;
import javax.json.bind.JsonbConfig;
JsonbConfig customJsonbConfig = new JsonbConfig()
.withNullValues(true); //para fins de exemplo; existem várias configurações disponíveis
MyApi myApi = new RestifyProxyBuilder()
.converters()
.add(new JsonBMessageConverter(customJsonbConfig))
.and()
.target(MyApi.class)
.build();
Copy import com.github.ljtfreitas.restify.http.client.message.converter.json.JsonBMessageConverter;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbConfig;
import javax.json.bind.JsonbBuilder;
JsonbConfig customJsonbConfig = new JsonbConfig()
.withNullValues(true);
Jsonb myJsonb = JsonbBuilder.create(customJsonbConfig);
MyApi myApi = new RestifyProxyBuilder()
.converters()
.add(new JsonBMessageConverter(myJsonb))
.and()
.target(MyApi.class)
.build();