Make JSON payload fields case insensitive when mapping to Java Object in REST API developed using SpringBoot

java, json, rest, spring, spring-boot

Solution

Well, if its Spring Boot application you can have this in your `application.properties` file: `spring.jackson.mapper.accept_case_insensitive_properties=true`

or if you use yaml:

spring:
  jackson:
    mapper:
      accept_case_insensitive_properties: true

Problem

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 is my code. Payload ``` {"limit":1,"name":"MATTHEW PHILLIPS"} ``` Request Object ``` private String limit; private String name; public String getLimit() { return limit; } public void setLimit(String limit) { this.limit = limit; } public String getName() { return name; } public void setName(String name) { this.name = name; } ``` I map the JSON payload to java Object directly using `@RequestBody` Spring annotation. My question here is How do I make the java Object to map to the fields ignoring the case. Regards, Rakesh

Original source