集合转json json转集合

集合转json json转集合

导包

xml 复制代码
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

集合转json

java 复制代码
import org.springframework.data.redis.core.StringRedisTemplate;

// 注入StringRedisTemplate
	@Autowired
    private StringRedisTemplate redisTemplate;


// 在某个方法里将
public void redisMenthod(){
    // 拿到集合 ZtAuthResource是我的实体类
    List<ZtAuthResource> list = list();
    
    // 存入redis
    redisTemplate.opsForValue().set("resourceList", JSON.toJSONString(list));
}

json转集合

java 复制代码
// 引的包
import com.alibaba.fastjson.JSONArray;

List<ZtAuthResource> redisResourceList = JSONArray.parseArray(redisResourceListStr, ZtAuthResource.class);
相关推荐
譕痕4 天前
JSONObject与JSONArray封装数据格式区别
java·json
A黄俊辉A4 天前
uniapp webview中实现 app和内嵌的H5双向通信
vue.js·json
伞伞悦读4 天前
【第37期】Python JSON 与配置详解:序列化、反序列化、嵌套结构和配置文件
开发语言·python·json
Mikko74 天前
jackson-databind 升到 2.21.6 就安全了吗?jackson-core 是另一个坐标,它那条 high 全局库至今没收
java·后端·安全·json
天若有情6736 天前
独立开发复盘:我用 Node.js 做了个在线工具箱
前端·json·工具
Asurplus7 天前
【SpringBoot4】3、从SpringBoot4升级Sa-Token1.46.0报错
redis·sa-token·json·jackson·springboot4
代码中介商7 天前
C++ 预约系统实战(三):服务端实现——libevent 事件驱动与业务路由
c++·json·c/s
譕痕8 天前
notepad++安装插件 可视化展示 json串内容
json·intellij-idea
databook8 天前
DuckDB + SQL 高效分析 JSON 数据
数据分析·json·nosql
数据狐(Datafox)9 天前
1688商品列表API接口解析(附 JSON 样例)
java·开发语言·数据库·爬虫·json