經過ObjectMapper將實體轉成字符串 ,將 用json存的的list 迴轉list

InvokingSecurityInfo invokingSecurityInfo;
ObjectMapper objectMapper = new ObjectMapper();
List<String> userAccountList=new ArrayList<>();
//將實體類存成字符串
invokingSecurityInfo = invokingSecurityUtil.invokingSecurityInfoRepository.getFirstByAvaiStatus(1);
String a=new ObjectMapper().writeValueAsString(invokingSecurityInfo)
//將實體類存成字符串
JavaType javaType =objectMapper.getTypeFactory().constructParametricType(ArrayList.class, String.class);
userAccountList = objectMapper.readValue(invokingSecurityUtil.redisService.get(INVOKING_USER_ACCOUNT).toString(), javaType);
相關文章
相關標籤/搜索