Serialize and Deserialize PageImpl in Jackson

It’s very common to put paginated query results in Redis via Jackson serialization and deserialization. However, doesn’t expose a default constructor. Even worse, that applies to and as well. There are a couple of workarounds. I’d like to introduce a less intrusive approach for your reference.

The idea is to write a Jackson module which injects a custom serializer and deserializer for Let’s see how to do that.

  1. Define an interface.

2. Define a Serializer.

3. Define a Deserializer.

4. Define a module.

5. Register the module.

Now Jackson is able to handle PageImpl and the Redis cache works.



Amateur programmer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store