集合转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);
相关推荐
半路_出家ren2 小时前
python处理异常,JSON
python·json·异常处理
傻小胖7 小时前
json-server的用法-基于 RESTful API 的本地 mock 服务
后端·json·restful
search78 小时前
配置文件介绍xml、json
xml·json
Chandler241 天前
Go语言:json 作用和语法
开发语言·golang·json
Hfc.2 天前
docker-daemon.json
docker·容器·json
UpUpUp……3 天前
Linux--JsonCpp
linux·运维·服务器·c++·笔记·json
wtsolutions3 天前
Excel-to-JSON插件专业版功能详解:让Excel数据转换更灵活
json·excel·excel-to-json·wtsolutions·专业版
kerryYG3 天前
使用JMETER中的JSON提取器实现接口关联
jmeter·json
柯ran4 天前
JSON|cJSON 介绍以及具体项目编写
c语言·链表·json·github
乐言3615 天前
Jmeter中的Json提取器如何使用?
jmeter·json