Case insensitive JSON to POJO mapping without changing the POJO

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

    An alternative solution is to specify JSON field names case-sensitive:

    public Movie(){
        //Jackson deserialize
    }
    @JsonProperty("Title")
    public String getTitle() {
        return title;
    }
    
    @JsonProperty("Year")
    public String getYear() {
        return year;
    }
    @JsonProperty("imdbID")
    public String getImdbID() {
        return imdbID;
    }
    

提交回复
热议问题