FastJSON配合Redis存取处理map数据

前端之家收集整理的这篇文章主要介绍了FastJSON配合Redis存取处理map数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码如下:

public void save(){

    Map<String,Object> map = new HashMap<String,Object>();
    map.put("bList",bList);
    map.put("sList",sList);
    map.put("tList",tList);
    map.put("aList",aList);
    map.put("gList",gList);
    map.put("updateTime",datetime);
    String str = JSONObject.toJSONString(map);
    this.cacheService.set(RedisKey.STop_LIST_ + String.valueOf(updateTime),str);
}
public  Map<String,Object> get(){
    Map<String,Object>();
    if (this.cacheService.exists(RedisKey.STop_LIST_ + dateStr)) {
        String jsonStr = this.cacheService.get(RedisKey.STop_LIST_ + dateWdjStr);
        Map<String,Object> result = (Map<String,Object>) JSON.parse(jsonStr);
        List<ViewVo> bList = JSONObject.parseArray(result.get("bList").toString(),ViewVo.class);
        List<ViewVo> sList = JSONObject.parseArray(result.get("sList").toString(),ViewVo.class);
        List<ViewVo> tList = JSONObject.parseArray(result.get("tList").toString(),ViewVo.class);
        List<ViewVo> aList = JSONObject.parseArray(result.get("aList").toString(),ViewVo.class);
        List<ViewVo> gList = JSONObject.parseArray(result.get("gList").toString(),ViewVo.class);
        Timestamp updateTime = JSONObject.parSEObject(result.get("updateTime").toString(),Timestamp.class);
        map.put("bList",bList);
        map.put("sList",sList);
        map.put("tList",tList);
        map.put("aList",aList);
        map.put("gList",gList);
        map.put("updateTime",updateTime);
        return  map;
        }
}@H_403_3@

猜你在找的Json相关文章