Skip to content

Commit

Permalink
Add mixin for string array
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Oct 29, 2024
1 parent 279ced5 commit 3d52213
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.orcid.frontend.spring.configuration;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.security.jackson2.CoreJackson2Module;
import org.springframework.security.jackson2.SecurityJackson2Modules;

@Configuration
Expand All @@ -25,11 +28,22 @@ public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
private ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModules(SecurityJackson2Modules.getModules(this.loader));
mapper.registerModules(new CoreJackson2Module());
mapper.addMixIn(String[].class, StringArrayMixin.class);
return mapper;
}

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.loader = classLoader;
}

@JsonTypeInfo(
use = JsonTypeInfo.Id.CLASS
)
abstract class StringArrayMixin {
@JsonCreator
StringArrayMixin(String[] array) {
}
}
}

0 comments on commit 3d52213

Please sign in to comment.