Overview

JSerde is a Java framework for serializing and deserializing data.

It is inspired by the Serde framework in Rust.

Core concepts

Serializing a value is the process of producing a representation that can be transported or stored. Deserializing is the reverse process of producing the same value from this representation.

Example 1. Different representations

The number 42 can be serialized in different ways, for example:

  • as a byte whose value is 42

  • as a sequence of two characters: 4 and 2

JSerde introduces a unique data model that allows the decoupling of the following roles:

  • the serializer knows how to produce data representing a value in the data model

  • the format knows how to write/read data in the data model to/from a specific representation

  • the deserializer knows how to produce a value from the data in the data model

Diagram
Figure 1. Serialization
Diagram
Figure 2. Deserialization

This separation of concerns makes the serialization strategies completely independent of the various formats.

The serializer and deserializer roles are often tightly related as they must follow the same rules to be compatible. They can however be used independently of each other if only serialization or deserialization is needed.