โ02-13-2023 12:58 AM
HI i have two arrays : 1.Name and 2. Values
Names = [
โkey1โ,โkey2โ,โkey3โ
]
Values = [
โValue1โ,โValue2โ,โValue3โ
]
I want output from snap as
{โkey1โ : โvalue1โ,
โkey2โ :โvalue2โ โฆ
}
Solved! Go to Solution.
โ02-13-2023 01:34 AM
Hi @ash42,
Do you want the output to be only one object?
If yes, then try with the following expression in a Mapper Snap:
$Names.reduce((acc,curr,ind) => acc.extend({[curr]: $Values[ind]}), {})
The output will look like this:
[
{
"key1": "Value1",
"key2": "Value2",
"key3": "Value3"
}
]
Let me know if this is the desired output.
BR,
Aleksandar.
โ02-13-2023 01:34 AM
Hi @ash42,
Do you want the output to be only one object?
If yes, then try with the following expression in a Mapper Snap:
$Names.reduce((acc,curr,ind) => acc.extend({[curr]: $Values[ind]}), {})
The output will look like this:
[
{
"key1": "Value1",
"key2": "Value2",
"key3": "Value3"
}
]
Let me know if this is the desired output.
BR,
Aleksandar.
โ02-13-2023 06:04 AM
Works for me ,Thank You