No Creators Exist: Cannot Deserialize
Solution 1:
If there is no constructors that is annotated with @JsonCreator
, by default, Jackson needs a default no-args constructor in order to parse the JSON into POJO or bean classes. That is why when you add a default constructor, it will work fine.
And if you don't actually need the usage of the default constructor, just add it for Jackson only, you can set it to private
, protected
or package-protected
. Jackson is still able to fill all the fields via reflection.
Regarding the no delegate- or property-based Creator
, they are constructors that is annotated with @JsonCreator
. In Jackson, there are 2 types of Creator/JsonCreator which are delegate-based Creator
and property-based Creator
.
Delegate-based creators take just one argument, which is NOT annotated with @JsonProperty. Type of that property is used by Jackson to bind the whole JSON value (JSON Object, array or scalar value), to be passed as value of that one argument.
Property-based creators take one or more arguments; all of which MUST be annotated with @JsonProperty, to specify JSON name used for property. They can only be used to bind data from JSON Objects; and each parameter represents one property of the JSON Object; type of property being used for binding data to be passed as that parameter when calling creator.
You can read for more details about these 2 creators in the article below. http://www.cowtowncoder.com/blog/archives/2011/07/entry_457.html