Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.bingoohuang.springrediscache;
 
 
 import java.util.List;
    private final Class<?> returnType;
    private final Logger logger;
    public JSONValueSerializer(Class<?> returnTypeLogger logger) {
        this. = returnType;
        this. = logger;
    }
    @Override
    public String serialize(Object value) {
        return JSON.toJSONString(value);
    }
    @Override
    public Object deserialize(String redisValueMethod method) {
        try {
            if (Map.class.isAssignableFrom()) {
                return JSON.parseObject(redisValueMap.class);
            }
            if (List.class.isAssignableFrom()) {
                Type genericReturnType = method.getGenericReturnType();
                if (genericReturnType instanceof ParameterizedType) {
                    Type type = ((ParameterizedTypegenericReturnType).getActualTypeArguments()[0];
                    return JSON.parseArray(redisValue, (Class<?>) type);
                }
            }
            return JSON.parseObject(redisValue);
        } catch (Exception e) {
            .error("unable to deserialize " + redisValuee);
            return null;
        }
    }
New to GrepCode? Check out our FAQ X