How to get Jackson to ignore constructorproperties
I'm trying to get Jackson to deserialize
"test": 2018
to
SomeJavaClass:
private final Test test
But I want to make my Test class using Project Lombok. However Lombok annotates the class with ConstructorProperties, and for some reason this makes jackson fail.
My classes looks like this:
@Value
public class SomeJavaClass
Test test;
@Value
public class Test
String value;
Test is delomboked as:
public class Test
int value;
@java.beans.ConstructorProperties("value")
public Test(final int value)
this.value = value;
public int getValue()
return this.value;
public boolean equals(final Object o)
if (o == this)
return true;
if (!(o instanceof Test))
return false;
final Test other = (Test) o;
if (this.getValue() != other.getValue())
return false;
return true;
public int hashCode()
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getValue();
return result;
public String toString()
return "Test(value=" + this.getValue() + ")";
Is it possible to make Jackson ignore the constructorproperties somehow?
java jackson lombok
add a comment |
I'm trying to get Jackson to deserialize
"test": 2018
to
SomeJavaClass:
private final Test test
But I want to make my Test class using Project Lombok. However Lombok annotates the class with ConstructorProperties, and for some reason this makes jackson fail.
My classes looks like this:
@Value
public class SomeJavaClass
Test test;
@Value
public class Test
String value;
Test is delomboked as:
public class Test
int value;
@java.beans.ConstructorProperties("value")
public Test(final int value)
this.value = value;
public int getValue()
return this.value;
public boolean equals(final Object o)
if (o == this)
return true;
if (!(o instanceof Test))
return false;
final Test other = (Test) o;
if (this.getValue() != other.getValue())
return false;
return true;
public int hashCode()
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getValue();
return result;
public String toString()
return "Test(value=" + this.getValue() + ")";
Is it possible to make Jackson ignore the constructorproperties somehow?
java jackson lombok
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
So what is the error, how does it make Jackson to fail? What annotations you use?@AllArgsConstructor?
– pirho
Nov 12 '18 at 17:13
add a comment |
I'm trying to get Jackson to deserialize
"test": 2018
to
SomeJavaClass:
private final Test test
But I want to make my Test class using Project Lombok. However Lombok annotates the class with ConstructorProperties, and for some reason this makes jackson fail.
My classes looks like this:
@Value
public class SomeJavaClass
Test test;
@Value
public class Test
String value;
Test is delomboked as:
public class Test
int value;
@java.beans.ConstructorProperties("value")
public Test(final int value)
this.value = value;
public int getValue()
return this.value;
public boolean equals(final Object o)
if (o == this)
return true;
if (!(o instanceof Test))
return false;
final Test other = (Test) o;
if (this.getValue() != other.getValue())
return false;
return true;
public int hashCode()
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getValue();
return result;
public String toString()
return "Test(value=" + this.getValue() + ")";
Is it possible to make Jackson ignore the constructorproperties somehow?
java jackson lombok
I'm trying to get Jackson to deserialize
"test": 2018
to
SomeJavaClass:
private final Test test
But I want to make my Test class using Project Lombok. However Lombok annotates the class with ConstructorProperties, and for some reason this makes jackson fail.
My classes looks like this:
@Value
public class SomeJavaClass
Test test;
@Value
public class Test
String value;
Test is delomboked as:
public class Test
int value;
@java.beans.ConstructorProperties("value")
public Test(final int value)
this.value = value;
public int getValue()
return this.value;
public boolean equals(final Object o)
if (o == this)
return true;
if (!(o instanceof Test))
return false;
final Test other = (Test) o;
if (this.getValue() != other.getValue())
return false;
return true;
public int hashCode()
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getValue();
return result;
public String toString()
return "Test(value=" + this.getValue() + ")";
Is it possible to make Jackson ignore the constructorproperties somehow?
java jackson lombok
java jackson lombok
edited Nov 12 '18 at 14:04
Astrogat
asked Nov 12 '18 at 12:09
AstrogatAstrogat
1,070615
1,070615
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
So what is the error, how does it make Jackson to fail? What annotations you use?@AllArgsConstructor?
– pirho
Nov 12 '18 at 17:13
add a comment |
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
So what is the error, how does it make Jackson to fail? What annotations you use?@AllArgsConstructor?
– pirho
Nov 12 '18 at 17:13
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
So what is the error, how does it make Jackson to fail? What annotations you use?
@AllArgsConstructor?– pirho
Nov 12 '18 at 17:13
So what is the error, how does it make Jackson to fail? What annotations you use?
@AllArgsConstructor?– pirho
Nov 12 '18 at 17:13
add a comment |
2 Answers
2
active
oldest
votes
I also think that the problem here is not the annotation @java.beans.ConstructorProperties("value").
Based on your delombok it seems that you have a set of annotations that will prevent default constructor to form.
So maybe you get rid of this problem by adding @NoArgsConstructor. Without default constructor and having no @JsonCreators you will have an error like:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
construct instance of org.example.spring.jackson.JacksonTest$TestClass
(although at least one Creator exists): cannot deserialize from Object
value (no delegate- or property-based Creator)
add a comment |
The reason why this fails is not the @ConstructorProperties. In fact, this annotation is required to make Jackson work with Lombok's @AllArgsConstructor.
The problem here is that the value of test in your JSON is an integer, but your class structure requires it to be an object. So you have to make the field test in SomeJavaClass an int. Then you also don't need the Test class. (Or rename value to test in Test and get rid of SomeJavaClass and deserialize to Test.)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261915%2fhow-to-get-jackson-to-ignore-constructorproperties%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I also think that the problem here is not the annotation @java.beans.ConstructorProperties("value").
Based on your delombok it seems that you have a set of annotations that will prevent default constructor to form.
So maybe you get rid of this problem by adding @NoArgsConstructor. Without default constructor and having no @JsonCreators you will have an error like:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
construct instance of org.example.spring.jackson.JacksonTest$TestClass
(although at least one Creator exists): cannot deserialize from Object
value (no delegate- or property-based Creator)
add a comment |
I also think that the problem here is not the annotation @java.beans.ConstructorProperties("value").
Based on your delombok it seems that you have a set of annotations that will prevent default constructor to form.
So maybe you get rid of this problem by adding @NoArgsConstructor. Without default constructor and having no @JsonCreators you will have an error like:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
construct instance of org.example.spring.jackson.JacksonTest$TestClass
(although at least one Creator exists): cannot deserialize from Object
value (no delegate- or property-based Creator)
add a comment |
I also think that the problem here is not the annotation @java.beans.ConstructorProperties("value").
Based on your delombok it seems that you have a set of annotations that will prevent default constructor to form.
So maybe you get rid of this problem by adding @NoArgsConstructor. Without default constructor and having no @JsonCreators you will have an error like:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
construct instance of org.example.spring.jackson.JacksonTest$TestClass
(although at least one Creator exists): cannot deserialize from Object
value (no delegate- or property-based Creator)
I also think that the problem here is not the annotation @java.beans.ConstructorProperties("value").
Based on your delombok it seems that you have a set of annotations that will prevent default constructor to form.
So maybe you get rid of this problem by adding @NoArgsConstructor. Without default constructor and having no @JsonCreators you will have an error like:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
construct instance of org.example.spring.jackson.JacksonTest$TestClass
(although at least one Creator exists): cannot deserialize from Object
value (no delegate- or property-based Creator)
answered Nov 12 '18 at 17:37
pirhopirho
3,945101830
3,945101830
add a comment |
add a comment |
The reason why this fails is not the @ConstructorProperties. In fact, this annotation is required to make Jackson work with Lombok's @AllArgsConstructor.
The problem here is that the value of test in your JSON is an integer, but your class structure requires it to be an object. So you have to make the field test in SomeJavaClass an int. Then you also don't need the Test class. (Or rename value to test in Test and get rid of SomeJavaClass and deserialize to Test.)
add a comment |
The reason why this fails is not the @ConstructorProperties. In fact, this annotation is required to make Jackson work with Lombok's @AllArgsConstructor.
The problem here is that the value of test in your JSON is an integer, but your class structure requires it to be an object. So you have to make the field test in SomeJavaClass an int. Then you also don't need the Test class. (Or rename value to test in Test and get rid of SomeJavaClass and deserialize to Test.)
add a comment |
The reason why this fails is not the @ConstructorProperties. In fact, this annotation is required to make Jackson work with Lombok's @AllArgsConstructor.
The problem here is that the value of test in your JSON is an integer, but your class structure requires it to be an object. So you have to make the field test in SomeJavaClass an int. Then you also don't need the Test class. (Or rename value to test in Test and get rid of SomeJavaClass and deserialize to Test.)
The reason why this fails is not the @ConstructorProperties. In fact, this annotation is required to make Jackson work with Lombok's @AllArgsConstructor.
The problem here is that the value of test in your JSON is an integer, but your class structure requires it to be an object. So you have to make the field test in SomeJavaClass an int. Then you also don't need the Test class. (Or rename value to test in Test and get rid of SomeJavaClass and deserialize to Test.)
edited Nov 12 '18 at 19:39
answered Nov 12 '18 at 14:18
Jan RiekeJan Rieke
9551213
9551213
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261915%2fhow-to-get-jackson-to-ignore-constructorproperties%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
does @JsonIgnoreProperties(ignoreUnknown = true) work for you? or this answer to a similar problem stackoverflow.com/questions/12835911/…
– codebrane
Nov 12 '18 at 12:20
Please add the full source code including all Lombok annotations.
– Jan Rieke
Nov 12 '18 at 13:53
There's an issue on GitHub about this problem: github.com/meltmedia/jackson-crypto/issues/6
– Hélio Márcio Filho
Nov 12 '18 at 14:20
So what is the error, how does it make Jackson to fail? What annotations you use?
@AllArgsConstructor?– pirho
Nov 12 '18 at 17:13