主要代码

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

 

 

 

 

 

 

 

 

 

 


fastjson 对类模板进行 parseObject

 

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-08-30
  • 2021-06-07
  • 2022-02-03
  • 2021-08-02
猜你喜欢
  • 2021-05-20
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-12-17
  • 2021-07-29
相关资源
相似解决方案