I am working on REST API developed using SpringBoot application. Here I want to make the fields in the payload(JSON) as case insensitive when mapping to a Java Object. Below
I recently found a solution via Annotation config:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@Configuration
public class Config {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
return mapper;
}
}
I'm using these dependencies:
org.springframework.boot
spring-boot-starter-parent
1.3.3.RELEASE
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-web
org.springframework
spring-core
com.fasterxml.jackson.module
jackson-module-jaxb-annotations
2.6.5
Good luck.