Function for replacing keys in collection or array

Hi Makers,

I didn’t find any function or combination of functions that would do pretty simple, yet (I guess) quite useful thing - replacing keys in collection or array.

Maybe you know of such function or a solution?

If not - what do you think of such a function? Could it be useful? (example below)

having such an input:
[
{
“a”: 1,
“b”: “alfa”,
“c”: [
{
“d”: “2024-01-01”,
“e”: 21.97
}
]
}
]

expecting such output:
[
{
“id”: 1,
“name”: “alfa”,
“pricings”: [
{
“date”: “2024-01-01”,
“price”: 21.97
}
]
}
]

using such function:
replace_keys(array_or_collection_to_change, collection_of_mappings);

with additional collection_of_mappings:
{
“a”: “id”,
“b”: “name”,
“c”: “pricings”,
“d”: “date”,
“e”: “price”
}

Regards,
Johnny

There is no such function in Make. I’m sure others would agree that this is a nice feature to have.

You can submit this suggestion to the Idea exchange, under Platform ideas and improvements.

Don’t forget to search for it first, just in case someone already suggested it, so that you don’t end up creating a duplicate.
Screenshot_2024-01-17_130153

It could be possible to do this using several modules and operations, but

In the meantime, you can workaround this by chaining the replace functions like this:

Screenshot_2024-02-20_140103

1 Like

Yup, that will do :slight_smile:
Thanks!