Como já tínhamos o Gson no projeto, fiquei me perguntando se poderia usá-lo também para fazer o que foi mostrado nesta aula. Ou existe alguma vantagem no Jackson que justifique a sua adição?
public void listarAbrigosCadastrados() throws IOException, InterruptedException {
String uri = "http://localhost:8080/abrigos";
HttpResponse<String> response = clientHttpConfiguration.dispararRequisicaoGet(uri);
String responseBody = response.body();
Type listType = new TypeToken<List<Abrigo>>() {}.getType();
List<Abrigo> abrigos = new Gson().fromJson(responseBody, listType);
System.out.println("Abrigos cadastrados: ");
for(Abrigo abrigo: abrigos) {
System.out.println(abrigo.getId() + " - " + abrigo.getNome());
}
}
Fiz dessa forma, está correto?