BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
5 / 81 · Module 3 — DataWeave 2.0 Crash Course · filtered: interview← prev⊞ allnext →

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)