主要代码
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; } }