I want to concatenate the values of a list of maps that share the same key. I have a list of maps that looks like this:
tags = [
{
key = "env"
value = "dev"
},
{
key = "project"
value = "tata"
},
{
key = "env"
value = "prod"
},
{
key = "project"
value = "tata"
},
{
key = "project"
value = "titi"
}
]
And I would like to convert it in the following way.
tags = [
{
key = "env"
value = ["dev", "prod"]
},
{
key = "project"
value = ["tata", "titi"]
}
]
Or better yet, like this:
tags = {
env = ["dev", "prod"]
project = ["tata", "titi"]
}
This post looks like my problem, but I couldn't adapt it to my case.
Thanks for your help.