fastjson的使用,在redis里面存list
fastjson是真的厉害厉害,哇,
少年不识愁滋味,为赋新词强说愁。如今尝尽愁,欲说还休。
public static void main(String[] args) { Jedis jedis = new Jedis("127.0.0.1",6379); User user1 = new User(1,"日不落",18); User user2 = new User(2,"发如雪",18); List<User> list = new ArrayList<>(); list.add(user1); list.add(user2); jedis.set("userList",JSON.toJSONString(list)); String userListStr = jedis.get("userList"); JSONArray userList = JSONObject.parseArray(userListStr); List<User> userList1 = (List<User>) JSON.toJSON(userList); System.out.println(userList); jedis.close(); }