Jackson not recognizing @JsonCreator annotation Jackson not recognizing @JsonCreator annotation json json

Jackson not recognizing @JsonCreator annotation


The annotation @JsonCreator requires the annotation @JsonProperty. This Jackson wiki page gives little information but does offer sample code:

@JsonCreatorpublic Name(@JsonProperty("givenName") String g, @JsonProperty("familyName") String f){  givenName = g;  familyName = f;}

You'll find a more detailed explanation at this blog post.

Your sample code should therefore look something like this:

@JsonCreatorpublic static XYZType getInstance(@JsonProperty("someCode") String code){ ...}


Problem is that Jackson only sees the declared base type, and does not know where to look for subtypes.Since full polymorphic type handling was added in 1.5, what you need to do with 1.4 is to add factory method in the base class and dispatch methods from there.