fastjson 对类模板进行 parseObject

主要代码

private PageEntity<HotelEsSource> genEntityByFile(String fileName) throws IOException {
    String json_Str = readToString(new File(getRoodDir() + fileName));
    return JSON.parseObject(json_Str, new TypeReference<PageEntity<HotelEsSource>>() {
    });
}

最主要的是 

new TypeReference<PageEntity<HotelEsSource>>() { }

 

这里PageEntity类模板的代码如下:

public class PageEntity<T> {

    private List<T> result;

    private Long totalSize;

    public List<T> getResult() {
        return result;
    }

    public void setResult(List<T> result) {
        this.result = result;
    }

    public Long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(Long totalSize) {
        this.totalSize = totalSize;
    }
}

 

 

 

 

 

 

 

 

 

 


 

posted @ 2020-07-15 17:59  yeren2046  阅读(763)  评论(0编辑  收藏  举报