Converting an object with key/values to a list
The following example automation shows you how to convert an object with key/values to a list (array):
In the automation, we loop over the properties of the object. Inside the loop, we use a temporary variable of type object, called newObj
. We set 2 keys in this object: property_name
and property_value
.
Property_name will be equal to the key of the item in the loop using { $.loop.index }:
Property_value will be equal to the value of the item in the loop using { $.loop.item }:
Finally, we add the temporary object newObj
to a variable of type list:
The result is that we have converted someObj to myList.
Original someObj object:
{
"key1": "val1",
"key2": "val2"
}
Final myList array:
[
{
"property_name": "key1",
"property_value": "val1"
},
{
"property_name": "key2",
"property_value": "val2"
}
]
See also Loop block for more information on how to loop over properties of an object.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!