# Jackson

## Instalação

Para utilizar o [Jackson](https://github.com/FasterXML/jackson), adicione a dependência `java-restify-json-jackson-converter`. O `converter` `JacksonMessageConverter` será automaticamente registrado.

### Maven

```markup
<dependency>
  <groupId>com.github.ljtfreitas</groupId>
  <artifactId>java-restify-json-jackson-converter</artifactId>
  <version>{version}</version>
</dependency>
```

### Gradle

```groovy
dependencies {
  compile("com.github.ljtfreitas:java-restify-json-jackson-converter:{version}")
}
```

## Utilização

```java
public interface MyApi {

  /* requisições e respostas com o content-type application/json
  serão automaticamente serializadas/deserializadas usando o jackson */

  @Path("/customers/{id}") @Get
  Customer findCustomer(@PathParameter String id);

  @Path("/customers") @Post
  @JsonContent
  Customer createCustomer(@BodyParameter Customer customer);
}
```

A implementação da classe `JacksonMessageConverter` utiliza uma instância do [ObjectMapper](https://fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/jackson/databind/ObjectMapper.html) do Jackson com configurações padrão. A única customização é a *feature* [FAIL\_ON\_UNKNOWN\_PROPERTIES](https://fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/jackson/databind/DeserializationFeature.html#FAIL_ON_UNKNOWN_PROPERTIES), que é definida como `false`.

Caso você precise de outras modificações, seu código pode gerar o `ObjectMapper` e instanciar o `JacksonMessageConverter` manualmente:

```java
import com.github.ljtfreitas.restify.http.client.message.converter.json.JacksonMessageConverter;
import com.fasterxml.jackson.databind.ObjectMapper;

ObjectMapper myObjectMapper = new ObjectMapper();
//configura o objectMapper da maneira que desejar...

MyApi myApi = new RestifyProxyBuilder()
  .converters()
    .add(new JacksonMessageConverter(myObjectMapper))
    .and()
  .target(MyApi.class)
    .build();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ljtfreitas.gitbook.io/java-restify/tipos-de-conteudo/list/json/jackson.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
