Deserialize Json to Pojo without case sensitivity

Viewed 10

I have been trying to figure out how to deserialize json coming from an API response to models and ignore case. I can get it to work with something like this:

Json:

{
    "Name": "foo"
}

Model:

@Data
public class Member {
    @JsonProperty("Name")
    private String name;
}

I have SOOOO many because for some reason the API returns properties in pascal case rather than camel. I dont really want to create a new mapper for something so trivial. I was hoping there was some property in spring boot that I could add to my applicaition yaml file.

Any ideas?

1 Answers

Try configuring like below it will work :)

@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
private String name;
Related