Skip to main content

For

Apply a list of transformations to each element of an array.

Example

This example shows how to use the For transformation to apply a list of transformations to each element of an array.

{
"operation": "for",
"arguments": {
"key": "items",
"transformations": [
{
"math_multiply_with_value": {
"key": "price",
"value": 1.1,
"new_key": "discounted_price"
}
},
{
"rename_key": {
"key": "name",
"new_key": "product_name"
}
}
]
}
}

Given the input record:

{
"items": [
{"name": "Item 1", "price": 100},
{"name": "Item 2", "price": 200},
{"name": "Item 3", "price": 300}
]
}

The output record will be:

{
"items": [
{"product_name": "Item 1", "price": 100, "discounted_price": 110},
{"product_name": "Item 2", "price": 200, "discounted_price": 220},
{"product_name": "Item 3", "price": 300, "discounted_price": 330}
]
}