Ở câu hỏi trước e có hỏi về cách map json về object. Nhưng khi em dùng generic thì nó không map được.
public class ApiResult { @JsonProperty("data") private List dataList; @JsonProperty("errorCode") private String code; @JsonProperty("errorMess") private String mess; } ResponseEntity responseEntity = restTemplate.exchange( api, HttpMethod.POST, httpEntity, ApiResult.class ); ApiResult apiResult = responseEntity.getBody();
thì nó sẽ như này ạ.
Em sẽ cần tạo ra 1 lớp Deserializer kiểu như thế này và đăng ký với object mapper kiểu như thế này nhé.