Customizable binding, with mapping from response body to java Object in UniRest

Before an asObject(Class) or a .body(Object) invokation, is necessary to provide a custom implementation of the ObjectMapper interface. This should be done only the first time, as the instance of the ObjectMapper will be shared globally.

For example, serializing Json from\to Object using the popular Jackson ObjectMapper takes only few lines of code.

// Only one timeUnirest.setObjectMapper(new ObjectMapper() {    private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper                = new com.fasterxml.jackson.databind.ObjectMapper();    public <T> T readValue(String value, Class<T> valueType) {        try {            return jacksonObjectMapper.readValue(value, valueType);        } catch (IOException e) {            throw new RuntimeException(e);        }    }    public String writeValue(Object value) {        try {            return jacksonObjectMapper.writeValueAsString(value);        } catch (JsonProcessingException e) {            throw new RuntimeException(e);        }    }});// Response to ObjectHttpResponse<Book> bookResponse = Unirest.get("http://httpbin.org/books/1").asObject(Book.class);Book bookObject = bookResponse.getBody();HttpResponse<Author> authorResponse = Unirest.get("http://httpbin.org/books/{id}/author")    .routeParam("id", bookObject.getId())    .asObject(Author.class);Author authorObject = authorResponse.getBody();// Object to JsonHttpResponse<JsonNode> postResponse = Unirest.post("http://httpbin.org/authors/post")        .header("accept", "application/json")        .header("Content-Type", "application/json")        .body(authorObject)        .asJson();