Case insensitive JSON to POJO mapping without changing the POJO

后端 未结 6 871
野性不改
野性不改 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:26

    You can solve this problem by configuring the mapper, as described by the @Nicolas Riousset.

    In addition, since version Jackson 2.9 you can do the same using annotation @JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) over a field or class, which is a more flexible option.

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

提交回复
热议问题