3.34Safe navigation / null handling
This is where developers get bitten.
Suppose:
{
"customerId": "C001"
}
and you try:
payload.billing.city
when billing doesn't exist.
You need to think defensively around optional structures.
Often you use combinations of:
default
conditional fields
validation before transformation
Example:
BillingCity:
payload.billing.city default null
But ask yourself whether null is actually what the downstream system should receive.
Often better:
(BillingCity: payload.billing.city)
if (payload.billing.city != null)