List< Object>转List<实体类>
List<Object> objectList = "Object类型集合";
List<Student> studentList= new ArrayList<Student>();
for (int i = 0; i < objectList.size(); i++) {
Student student = new Student();
Object[] obj = (Object[])objectList.get(i);
student.setId((Integer)obj[0]);
student.setTitle(obj[1].toString());
student.setOriginalText(obj[2].toString());
student.setImgPath(obj[3].toString());
student.setCreateDate((Timestamp)obj[4]);
student.setUserId((Integer)obj[5]);
student.setCategoryId((Integer)obj[6]);
student.setIsDelete((Integer)obj[7]);
studentList.add(tblTopic);
}
List< JSONObject>转List<实体类> (以及Stream过滤JSONArray数据)
JSONArray searchRecordAllData="JSONArray类型数据";
List<MorningCheckVo> normalList=new ArrayList<>();
//体温正常数据
List<Object> hikNormalList = searchRecordAllData.stream()
.filter(t -> ((JSONObject) t).getString("alarmTime").contains(recordDate))
.filter(t -> ((JSONObject) t).getString("overTemp").equals("0"))
.collect(Collectors.toList());
if(!hikNormalList.isEmpty()){
for(int i=0;i<hikNormalList.size();i++){
MorningCheckVo morningCheckVo=new MorningCheckVo();
JSONObject obj = (JSONObject)hikNormalList.get(i);
morningCheckVo.setVisiblePictureUri(obj.getString("visiblePictureUri"));
morningCheckVo.setTemp(obj.getString("temp"));
morningCheckVo.setAlarmTime(obj.getString("alarmTime"));
morningCheckVo.setPersonName(obj.getString("personName"));
normalList.add(morningCheckVo);
}
}