Extract Nested Email from Webhook JSON in n8n
You received a new order payload via an n8n Webhook node. You need to reference the customer's email address to send a confirmation message.
Incoming Payload / Data:
{
"order_id": 9482,
"customer": {
"name": "Alex Morgan",
"contact": {
"email": "[email protected]"
}
}
}
βοΈ Your expression is executed against test data β any correct solution passes. +10 XP
β Solution & explanation
Output: [email protected]
$json. Each dot walks one level deeper into the object: customer β contact β email. Bracket notation ($json['customer']['contact']['email']) does the same thing and is required when a key contains spaces or dashes, e.g. $json['first name'].π‘ Pro tip: If a level might be missing, use optional chaining β $json.customer?.contact?.email β so the node returns empty instead of throwing an error.
Also accepted: customer['contact']['email']