Dan
Dan

Reputation: 463

resolving com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field

This example works fine for me in my eclipse. However, when I have changed the Person class to the following :

package com.thejavageek.jaxrs.model;

public class Person {


private int userSelectList;

    public int getUserSetSelectList() {
        return userSelectList;
    }

    public void setUserSetSelectList(int userSelectList) {
        this.userSelectList = userSelectList;
    }





    @Override
    public String toString() {

        return "Person [userSelectSet=" + userSelectList + "]";
    }

}

And I tested by passing the JSON like the following :

enter image description here

Error:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "userSelectList" (class com.thejavageek.jaxrs.model.Person), not marked as ignorable (one known property: "userSetSelectList"])
 at [Source: io.undertow.servlet.spec.ServletInputStreamImpl@6418702f; line: 1, column: 20] (through reference chain: com.thejavageek.jaxrs.model.Person["userSelectList"])

Why is it that the example form the link I shared above works fine and not this one?

Upvotes: 1

Views: 3162

Answers (1)

int21h
int21h

Reputation: 839

In your json, change "userSelectList" to "userSetSelectList", or change your setter to "setUserSelectList"

Upvotes: 2

Related Questions