This gist outlines an approach to generic deserialization in Kotlin, using Vavr (which provides the Either functionality) and Jackson (for deserialization).
What it gives you is:
- A single deserialization method for turning JSON into object graphs
- The option to use custom deserialization methods for individual fields - or all fields of a particular data type
- Little to no rework when the JSON model changes, beyond updating your data classes
In exchange all that is required is that the naming and structure of your model classes mirror your JSON naming and structure.