I am in trouble, here is a class I want to Serialize/Deserialize with Jackson 2.3.2. The serialization works fine but not the deserialization.
I have this exception as below:
No suitable constructor found for type [simple type, class Series]: can not instantiate from JSON object (need to add/enable type information?)
The weirdest thing is that it works perfectly if I comment the constructor!
public class Series {
private int init;
private String key;
private String color;
public Series(String key, String color, int init) {
this.key = key;
this.init = init;
this.color = color;
}
//Getters-Setters
}
And my unit test :
public class SeriesMapperTest {
private String json = "{\"init\":1,\"key\":\"min\",\"color\":\"767\"}";
private ObjectMapper mapper = new ObjectMapper();
@Test
public void deserialize() {
try {
Series series = mapper.readValue(json, Series.class);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
}
This exception is throwing from the method deserializeFromObjectUsingNonDefault() of BeanDeserializerBase of Jackson lib.
Any idea?
Thanks