Taras Velykyy
Taras Velykyy

Reputation: 1801

Jackson conflicting property and getter definitions

I'm extending following third-party class which I can't change:

public class Page {
    @JsonProperty("content")
    private String content;

    public String getContent() {};
}

My implementation of Page looks like this:

public class MyPage extends Page {
    @JsonProperty("my-content")
    public String getContent() {return super.getContent()};
}

When I'm trying to serialize instance of MyPage class I get the following exception:

java.lang.IllegalStateException: Conflicting property name definitions:  
'content' (for [field com.test.Page#content]) 
vs
'my-content' (for [method com.test.MyPage#getContent(0 params)])

Is there an easy way to force serializer to produce 'my-content' property?

Upvotes: 3

Views: 4765

Answers (1)

frenchu
frenchu

Reputation: 308

I guess the issue was solved in Jackson 2.4.0. Please check https://github.com/FasterXML/jackson-databind/issues/193.

Try to update your Jackson library to 2.4.0 or above.

Upvotes: 1

Related Questions