. Advertisement .
..3..
. Advertisement .
..4..
If you have suddenly started getting the error “No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator”, then it can be a real nightmare. The problem seems to appear out of nowhere and no amount of troubleshooting seems to fix it. Here is one of the most effective ways to fix this error. Read on.
What is “No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator”?
You may have trouble with the following error when use Retrofit và Jackson
No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator
How to fix the error?
If you get the above error, it is most likely because you are not using the Jackson module for Kotlin. Here are some solutions for you:
Option 1: Include an empty constructor
Simply include an empty constructor like this:
@JsonProperty("field_name")
Option 2: For using Lobok và @Data
Instead of using:
@Data static class LoginResponse { private final String token, message; private final int status; }
Let’s convert to:
@Data static class LoginResponse { private String token, message; private int status; }
Option 3: Include a default constructor
This approach resembles Solution 1 in many ways. All you have to do now is include a default constructor. Your problem should now be resolved. For example:
@AllArgsConstructor
@NoArgsConstructor
@Getter
@ToString
@EqualsAndHashCode
public class User {
private Long userId;
private String shortName;
}
Conclusion
We hope you enjoyed our blog post on how to solve the bug “No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator”. Please leave a comment if you have any further questions or concerns regarding this topic. Thank you for taking the time to read; we are always delighted anytime one of our pieces can give important information on this topic!
Leave a comment