When unmarshalling a object which has a Instant datatype, I am getting the below exception. Any pointers to resolve the issue?
I am trying to resolve it with java 8 Instant datatype, don't prefer to convert to LocalDate or another datatypes.
Exception in thread "main" java.lang.IllegalArgumentException: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.time.Instant: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [{"transactionType":"ADD_DOC","payload":{"hash":"hashofthedocument12","userId":"123","meta":{"key1":"data1","key2":"data2"}},"consensusTimestamp":{"epochSecond":1522205987,"nano":533000000},"id":"2aaa3863-062d-4fcc-a789-8aad3dfade57"}]; line: 1, column: 148] (through reference chain: java.lang.Object[][0]->ipos.hashgraph.model.ConsensedDocument["consensusTimestamp"])
at ipos.hashgraph.marshaller.JacksonMarshaller.unmarshalLenient(JacksonMarshaller.java:50)
at ipos.hashgraph.loadtest.LoadTestor.getTransaction(LoadTestor.java:61)
at ipos.hashgraph.loadtest.LoadTestor.main(LoadTestor.java:99)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.time.Instant: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [{"transactionType":"ADD_DOC","payload":{"hash":"hashofthedocument12","userId":"123","meta":{"key1":"data1","key2":"data2"}},"consensusTimestamp":{"epochSecond":1522205987,"nano":533000000},"id":"2aaa3863-062d-4fcc-a789-8aad3dfade57"}]; line: 1, column: 148] (through reference chain: java.lang.Object[][0]->ipos.hashgraph.model.ConsensedDocument["consensusTimestamp"])
Code:
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
try {
mapper.readValue(responseEntity1.getBody(), ConsensedDocument[].class);
} catch (IOException e) {
e.printStackTrace();
}
Model Object
String transactionType;
Document payload;
Instant consensusTimestamp;
UUID id;