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