集合转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);
相关推荐
Promise微笑5 小时前
Geo专家于磊:Json-LD优化实战SOP与双核四驱体系
大数据·人工智能·重构·json
专注VB编程开发20年5 小时前
json和python元组,列表,字典对比
开发语言·python·json·php
奇树谦6 小时前
深度解析 compile_commands.json:源码到目标码映射的核心枢纽
json
alwaysrun7 小时前
C++之轻量级JSON序列库jsoncpp
c++·json·编程语言
彭于晏Yan7 小时前
HttpServletRequest 如何读取JSON请求体
spring boot·后端·json
csdn小瓯8 小时前
结构化输出实战:Pydantic Schema约束LLM生成JSON
json·状态模式
Dxy12393102161 天前
Python请求方式介绍:JSON、表单及其他常见数据传输格式
数据库·python·json
龙侠九重天1 天前
大型语言模型结构化输出:用 JSON Schema 约束大模型输出
人工智能·语言模型·自然语言处理·大模型·json
原来是猿2 天前
网络计算器:理解序列化与反序列化(下)
linux·开发语言·网络·网络协议·json·php
SelectDB技术团队2 天前
强行拍平?全表扫描? AI Agent 动态 JSON 的观测分析
数据库·人工智能·json·apache doris