Changing the name of the property from Symbol to symbol won’t help since we still have the "Symbol" in the json file.

You can try to use the @JsonProperty annotation like in the example. For the "Symbol" json field it can look like this:

//...
    private String Symbol;

    @JsonProperty("Symbol")
    public String getSymbol() {
        return this.Symbol;
    }

    @JsonProperty("Symbol")
    public void setSymbol(String symbol) {
        this.Symbol = symbol;
    }
// ...

This approach should also work for other fields which differ from the json counterpart by the uppercase / lowercase letter.

edit: Just like in the answer from the question linked in my comment above – paraphrasing it:

Since your setter method is named setSymbol() Jackson assumes the variable is named symbol because of the Java naming conventions (variables should start with lower case letters).

edit(2): Other option would be leveraging the object mapper configuration. So instead of the annotations approach you could use the approach from here and make the mapper case insensitive:

objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);

Other property I find useful is:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

described in the Baeldung’s article linked above

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top