Model class for Jackson Parser to parse Uppercase properties

后端 未结 4 850
生来不讨喜
生来不讨喜 2021-01-18 02:21

I have a json file which looks like this:

{
    \"ANIMALS\": {
    \"TYPE\": \"MAMMAL\",
    \"COLOR\": \"BLACK\",
    \"HEIGHT\": \"45\",

    }
}
         


        
4条回答
  •  忘掉有多难
    2021-01-18 03:01

    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 :

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);    
    

提交回复
热议问题