list<entity>转list<map>


@SuppressWarnings("unchecked")
public static List> listConvert(List list) {
  List> list_map = new ArrayList>(); // 定义List>数组
          // list为外部传进来的list集合
  if (list != null && list.size() > 0) {
    list.forEach(item ->{
      // PropertyUtils.describe(Object)转换
      Map map = new HashMap();;
      try {
        map = (Map) PropertyUtils.describe(item);
      } catch (Exception e) {
        e.printStackTrace();
      }
      list_map.add(map);
    });
  }
  return list_map;
}