- 字符串JSON转集合(JSONUtil.toList())
String shopTypeJson = stringRedisTemplate.opsForValue().get(shopTypeKey);//shopTypeKey:缓存中的KEY
List<ShopType> shopTypeList = JSONUtil.toList(shopTypeJson,ShopType.class);//ShopType.class:(对象)
- 集合转字符串JSON(JSONUtil.toJsonStr())
List<ShopType> shopTypeList = shopTypeService.query().orderByAsc("sort").list();//sort对象里的字段(int)
stringRedisTemplate.opsForValue().set(shopTypeKey, JSONUtil.toJsonStr(shopTypeList));
标签:toList,常用,ShopType,JSONUtil,JSON,shopTypeList,方法,shopTypeKey From: https://www.cnblogs.com/nkcell/p/17208878.html