|
|
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
|
|
import org.springframework.data.redis.serializer.SerializationException;
|
|
|
+import com.alibaba.fastjson.parser.Feature;
|
|
|
import com.alibaba.fastjson.parser.ParserConfig;
|
|
|
import org.springframework.util.Assert;
|
|
|
import java.nio.charset.Charset;
|
|
|
@@ -28,6 +29,8 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
|
static
|
|
|
{
|
|
|
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
|
|
|
+ // FastJSON 1.2.68+ 必须显式添加白名单
|
|
|
+ ParserConfig.getGlobalInstance().addAccept("com.fs.");
|
|
|
}
|
|
|
|
|
|
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
|
|
@@ -55,7 +58,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
|
}
|
|
|
String str = new String(bytes, DEFAULT_CHARSET);
|
|
|
|
|
|
- return JSON.parseObject(str, clazz);
|
|
|
+ return (T) JSON.parseObject(str, Object.class, Feature.SupportAutoType);
|
|
|
}
|
|
|
|
|
|
public void setObjectMapper(ObjectMapper objectMapper)
|