com.owlike.genson.JsonBindingException: No constructor has been found for type class org.threeten.bp.OffsetDateTime
Closed this issue · 1 comments
marcodifalco commented
Hi
I have this class
import org.threeten.bp.OffsetDateTime;
public class AccessTokenPayloadApiModel {
@SerializedName("aud")
private String aud = null;
@SerializedName("exp")
private OffsetDateTime exp = null;
public AccessTokenPayloadApiModel aud(String aud) {
this.aud = aud;
return this;
}
/**
* Get aud
* @return aud
**/
@ApiModelProperty(value = "")
public String getAud() {
return aud;
}
public void setAud(String aud) {
this.aud = aud;
}
public AccessTokenPayloadApiModel exp(OffsetDateTime exp) {
this.exp = exp;
return this;
}
/**
* Get exp
* @return exp
**/
@ApiModelProperty(example = "2840137200", value = "")
public OffsetDateTime getExp() {
return exp;
}
public void setExp(OffsetDateTime exp) {
this.exp = exp;
}
}
When i try to deserialize json
Genson genson=new Genson();
AccessTokenPayloadApiModel t = genson.deserializeInto(token, new AccessTokenPayloadApiModel());
I receive this error:
errore Could not deserialize to property 'exp' of class class io.swagger.client.model.AccessTokenPayloadApiModel.
In debug i see that the method BeanDescriptor.deserialize, line 95 catch a throw new JsonBindingException("No constructor has been found for type class org.threeten.bp.OffsetDateTime.
Why? What can i do?
Thanks
EugenCepoi commented
OffsetDateTime needs to have a no arg constructor or you need to enable support for deserialization using constructors with arguments via gensonBuilder.useConstructorWithArguments(true)
, see docs.
This is not an issue but a question. As such please use the proper channel (google groups) instead of github issues.