首页 > 移动平台 > 详细

ObjectMapper

时间:2014-11-20 18:35:25      阅读:479      评论:0      收藏:0      [点我收藏+]

    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;
    }
    
}

ObjectMapper

原文:http://www.cnblogs.com/yqlwl66/p/4111041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!