Understanding the serialization process
Serialization is the process of transforming complex objects or primitive data into a valid data type that can be transmitted to the client. A valid data type is a String, a Stream, or a Buffer.
In the Understanding validation and serialization section, we introduced the concept of Fastify’s serialization process, which uses JSON schemas to adapt a response payload to a defined format. This is the only task that this process carries out. It doesn’t apply any sort of validation of the output. This is often confusing because the JSON Schema is associated with the validation phase. Therefore, it would be more appropriate to compare it to filter processing rather than to a validation.
The actors in action are quite similar to what we saw in the Building a new validator compiler section, with some additions. In the following diagram, Figure 5.5, we are going to present these additions, extending the Serialization box we saw in...