I have a json file which looks like this:
{
"ANIMALS": {
"TYPE": "MAMMAL",
"COLOR": "BLACK",
"HEIGHT": "45",
}
}
But I get property not found error. If I change it to animals(lowercase). it works fine. Can anyone suggest me the model class for this sample json file which will get parsed correctly.
You should implement new naming strategy for your case:
After that, configure
ObjectMapper
See also
@JsonProperty
annotation.Thanks I solved this issue using @JsonProperty annotation
Building off of Deepak's answer, depending on how you have Jackson configured, you may need to put the
@JsonProperty
on the getters & setters instead of the property or you might get duplicate properties in the resulting JSON.Example
Results in...
{animals:"foo",ANIMALS:"foo"}
Results in...
{ANIMALS:"foo"}
If you are not generating the JSON (serialisation), but you want to consume an object without having to care about the case.
You can receive Animal or AniMal :