JSONUtil常用方法
- 字符串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));

浙公网安备 33010602011771号