Unrecognized field JSON

Exception text:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field <field_name> (class <class_name>), 
not marked as ignorable at <source>

Most likely the code looks like this:

class Foo implements Serializable {
    private static final long serialVersion UID = 987654321L;
    private String var1 = "12345";

    public String getVar2() {
        return var1;
    }
    public void setVar2(String value) {
        this.var1 = value;
    }
}

The error is that the names of getter and setter are not consistent with the corresponding field. getVar2() and setVar2() should be named getVar1() and setVar1():

public String getVar1() {
	return var1;
}

public void setVar1(String value) {
	this.var1 = value;
}
Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *