Case insensitive JSON to POJO mapping without changing the POJO

后端 未结 6 874
野性不改
野性不改 2020-11-27 21:06

Does anyone know how com.fasterxml.jackson.databind.ObjectMapper is able to map JSON properties to POJO properties case insensitive?

JSON-String:

6条回答
  •  隐瞒了意图╮
    2020-11-27 21:20

    This behaviour was introduced in Jackson 2.5.0. You can configure the mapper to be case insensitive using MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES.

    For example :

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

提交回复
热议问题