The way the serialization code is generated is driven by annotations. The most important one, Serializable, lets the compiler know to generate the extra classes for the target class.
Sometimes you might not have control over the field names you get in the incoming payload. Maybe your microservice processes events from a third party and the input is JSON. The reverse is also possible where your microservice produces data for third parties and they certain field names. Imagine a payload provided with the following structure:
{
“mid”: “abc”,
“value”: 1220.00
}
This is a simple entry to represent a transaction for a merchant. The mid field is the merchant identifier, while the value field represents the actual amount transacted. Through the SerialName annotation, you can control the mapping between the incoming payload fields...