Skip to content

Commit

Permalink
✨ mica-redis 添加 enableKotlinJson 配置,用于判断是否需要处理 Kotlin json 序列化
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xunhuan committed Oct 30, 2024
1 parent 1365518 commit e0c4a1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class MicaRedisProperties {
* 序列化方式
*/
private SerializerType serializerType = SerializerType.JSON;
/**
* 开启 Kotlin json 序列化
*/
private boolean enableKotlinJson = false;
/**
* key 过期事件
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public RedisSerializer<Object> redisSerializer(MicaRedisProperties properties) {
objectMapper.findAndRegisterModules();
// class type info to json
GenericJackson2JsonRedisSerializer.registerNullValueSerializer(objectMapper, null);
if (KotlinDetector.isKotlinPresent()) {
if (KotlinDetector.isKotlinPresent() && properties.isEnableKotlinJson()) {
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.EVERYTHING, As.PROPERTY);
} else {
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(), ObjectMapper.DefaultTyping.NON_FINAL, As.PROPERTY);
Expand Down

0 comments on commit e0c4a1f

Please sign in to comment.