java obj 转 list ,数据类型为自定义对象

    public static List<ContractModel> objToList(Object obj){
        List<ContractModel> result = new ArrayList<ContractModel>();
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            if (obj instanceof ArrayList<?>) {
                for (Object o : (List<?>) obj) {

                    result.add(objectMapper.convertValue( o,ContractModel.class));
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

 

posted @ 2022-05-27 14:36  Li_ll  Views(320)  Comments(0Edit  收藏  举报