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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With