Skip to content
Advertisement

Convert from object to AWS Kinesis -> Java Cannot deserialize instance of `java.util.Date` out of VALUE_NUMBER_FLOAT token

I am working on a AWS lambda function in order to get dynamically a SNS Event or a Kinesis Event, to do so, in my lambda function I am getting an Object as parameter:

JavaScript

Then, I am using Jackson in order to convert it to SNS or Kinesis dynamically:

JavaScript

The problem is that, when I’m using the convertToKinesisEvent function I am getting:

JavaScript

SNSEvent convertion works fine, but Kinesis does not, I have realized that is because in the Kinesis Json, the time stamp (approximateArrivalTimestamp field) is represented with decimals:

JavaScript

If I execute the same code with a integer in the timestamp it works fine:

JavaScript

Here is the full error log:

JavaScript

Does someone know what is happening?

–Update– Dependencies:

JavaScript

Thanks

Advertisement

Answer

Ok, so what I ended up doing was to add my custom deserializer to Jackson in order to solve the problem:

JavaScript

And then add a custom serializer

JavaScript

And then add it to Jackson and it worked, I don’t know if there is another solution but It achieve my goal

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement