Serializers

Let’s learn about serialization and its importance in clean architecture.

Outer layers can use the Room model, but if we want to return the model itself due to an API call, we need a serializer.

The typical serialization format is JSON, since this is a broadly accepted standard for web-based APIs. The serializer is not a part of the model but is actually a specialized external class that receives the model instance and represents its structure and values.

Test case for JSON serialization

The following is the test for the JSON serialization of our Room model:

Get hands-on with 1200+ tech skills courses.