一、数组操作
//数组中获取一列的数据
List<String> nameList = userList.stream().map(SysUser::getUserName).collect(Collectors.toList());
//按指定字段排序
Collections.sort(userList, new Comparator<SysUser>() {
@Override
public int compare(SysUsero1, SysUsero2) {
return o1.getUserName() - o2.getUserName();
}
});
二、JSON操作
//获取多个javabean
JSONObject json = JSON.parseObject(body);
Stu s = json.getObject("en", Stu.class);
Teacher t = json.getObject("en2", Teacher .class);
//获取数组
List<Stu > stuList = json.getJSONArray("ens").toJavaList(Stu.class);