ObjectMapper
String jsonStr="";
String content=jsonStr;
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(SearchResult.class,SearchProduct.class);
SearchResult<SearchProduct> searchResult = objectMapper.readValue(content, javaType);
List<ProductView> datas = new ArrayList<ProductView>();
for(SearchProduct product:searchResult.getResultList()){
}
public class SearchResult<T> {
private int totalItem;
private List<T> resultList;
public int getTotalItem() {
return totalItem;
}
public void setTotalItem(int totalItem) {
this.totalItem = totalItem;
}
public List<T> getResultList() {
return resultList;
}
public void setResultList(List<T> resultList) {
this.resultList = resultList;
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。