cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Map Key value pairs function

JensDeveloper
Contributor II

Hi,

Iโ€™m having it very difficult to fill the value of a key/value pair wit another value.
I Have an object that consists of a list of strings that are each unique. but with each string inside the object there is a value outside the object for each item in the list (The Value). The goal is to put for every item in the list of the object to change the value of a,b,c to the value of the key โ€œValue1โ€, โ€œValue2โ€ See below
Before
[
{
โ€œNameโ€ : {
โ€œaโ€ : โ€œaโ€
},
โ€œValue1โ€ : โ€œrandomvalueโ€
},
{
โ€œNameโ€ : {
โ€œbโ€ : โ€œbโ€
},
โ€œValue2โ€ : โ€œrandomValueโ€
}
]

After
[
{
โ€œNameโ€ : {
โ€œaโ€ : โ€œrandomvalue of Value1โ€
},
โ€œValue1โ€ : โ€œrandomvalueโ€
},
{
โ€œNameโ€ : {
โ€œbโ€ : โ€œrandomvalue of Value2โ€
},
โ€œValue2โ€ : โ€œrandomValueโ€
}
]

If there is anything thatโ€™s not understandable, let me know. Thanks in advance.

1 ACCEPTED SOLUTION

AleksandarAngel
Contributor III

Hi @JensDeveloper,

Please try with the following expression in a Mapper snap and let me know if it helps you
$Name.mapValues(x=>$.entries()[1][1])

BR Aleksandar.

View solution in original post

2 REPLIES 2

AleksandarAngel
Contributor III

Hi @JensDeveloper,

Please try with the following expression in a Mapper snap and let me know if it helps you
$Name.mapValues(x=>$.entries()[1][1])

BR Aleksandar.

YES it works, wow!
Sorry but I was struggling a lot with language expressions and functions so I am Relieved. Thank you. I still need to learn a lot but I love it!