ObjectMapper ObjectMapper = new ObjectMapper(); objectMapper.configure(Feature.IGNORE_UNKNOWN,true); objectMapper.configure(Feature.WRITE_BIGDECIMAL_AS_PLAIN,true); objectMapper.configure(JsonParser.Feature.ALLOW_MISSING_VALUES,true); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES,false); // Case desensitization is false by default. Change it to TRuCopy the code

reference

com.fasterxml.jackson.databind.MapperFeature#ACCEPT_CASE_INSENSITIVE_PROPERTIES

Use annotations: examples

public static void main(String[] args) throws IOException {
        String x = "{\n"
            + "        \"TToUserName\":\"gh_a5624dd2db4e\",\n"
            + "        \"FFromUserName\":\"ochvq0Kn35VlnTAcIJ3fRBAZTQUY\""
            + "       }";

        ObjectMapper objectMapper = new ObjectMapper();
        Result map = objectMapper.readValue(x, Result.class);
        System.out.println(map);
        objectMapper.writeValue(System.out,map);
    }



    private static class Result {

        private String ToUserName;
        private String FromUserName;

        @JsonProperty("ToUserName")
        public String getToUserName() {
            return ToUserName;
        }

        @JsonProperty("TToUserName")
        public void setToUserName(String toUserName) {
            ToUserName = toUserName;
        }

        @JsonProperty("FromUserName")
        public String getFromUserName() {
            return FromUserName;
        }

        @JsonProperty("FFromUserName")
        public void setFromUserName(String fromUserName) {
            FromUserName = fromUserName;
        }
    }
Copy the code