Given the following JSON
{
"obj" : {
"f1" : "blah",
"f2" : "blah",
"f3" : [{"z1" : "blah", "arr" : [{"m1" : "blah", "m2" : "blah"}]}]
}
}
I have tired using @JsonProperty
and @JsonCreator
in order to map "m1"
and "m2"
values, but with no luck.
With @JsonCreator public Card(Map<String,Object> props) { }
i get the following error:
Argument #0 of constructor [constructor for MyObj$Obj$Card, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator()}] has no property name annotation; must have name when multiple-paramater constructor annotated as Creator
With @JsonCreator public Card(@JsonProperty("m1") String m1, @JsonProperty("m2") String m2,){}
I get the following error:
Argument #0 of constructor [constructor for MyObj$Obj$Card, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator()}] has no property name annotation; must have name when multiple-paramater constructor annotated as Creator
How can the fields of "arr"
be mapped using Jackson annotation?
Thanks.
UPDATE
I also tried to include @JsonProperty("arr") private Card[] cards;
on f3
class, but it did not help either.
UPDATE 2
I have changed the array type in the update above, and now I do not get the error but it does not behaves as I wish (I would like to handle the mapping).
Is there any chance one could explain the error in a way that I could correct them.