比如:String str = '{var :[{ page:1},{page:2}]}";
思路:这个字符串数据最外围是一个map,而里面是一个集合,首先将其转为map,在通过key获取到value。再转为集合对象
Map maps = (Map) JSON.parse(str );
List contractList = JSON.parseArray(maps.get(“var”).toString(),Contract.class);
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>