集合转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);
相关推荐
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ9 小时前
Spring‑AI Document 对象 JSON 字段详解
人工智能·spring·json
sunywz10 小时前
【从零搭建物联网智能充电桩系统】2、自定义二进制协议:设备为什么不用 JSON?
python·物联网·json
灵析表格12 小时前
灵析表格手机号处理函数深度分析报告
前端·网络·json·wps·灵析表格·excel公式盒子
猿长大人1 天前
C# | JSON 序列化中的多态接口处理:基于 Attribute 实现精准 $type 控制
c#·json
消失的旧时光-19431 天前
第六篇:Redis Hash——一个用户对象应该保存成 JSON,还是保存成 Hash?
redis·json·哈希算法
SEO_juper1 天前
2026年Schema自动注入实战:用Python批量给1000个页面加上JSON-LD,AI引用率实测提升38%
人工智能·python·json·seo·独立站
Wang's Blog2 天前
AI Agent白手起家37: LangChain 输出解析器实战:文本、JSON、XML 与 Pydantic
xml·langchain·json
灵析表格2 天前
json_ObjectToKV 函数深度研究报告
json·excel·wps·灵析表格·excel公式盒子
wtsolutions2 天前
JSON 怎么导入 WPS?怎么转换成 WPS 表格?WPS 怎么打开 JSON?完整教程
json·wps
IDIOT___IDIOT3 天前
JSON-RPC 2.0 与 MCP 协议:从消息格式到进程通信 大模型MCP
rpc·大模型·json·agent·mcp