โ05-04-2022 01:04 AM
Hello Team,
I have my input coming like this,
[{โ@propertyTypeKeyโ:โActive_Flagโ,โ@propertyTypeOwnerโ:โ4918โ,โvalueโ:โYโ},
{โ@propertyTypeKeyโ:โData_flagโ,โ@propertyTypeOwnerโ:โ4918โ,โvalueโ:"N}]
I need to get my output like below,
โActive_Flagโ = โYโ
โData_flagโ = โNโ
Added above is a small example like this I have an big array from that i need to extract key and values as mentioned in the sample example. Could any of you please help me with this requirement.
Solved! Go to Solution.
โ05-04-2022 01:14 AM
Hi @Manigandan,
Use this expression
{array}.map(x => {[x[โ@propertyTypeKeyโ]]: x.value})
Regards
Viktor
โ05-04-2022 01:14 AM
Hi @Manigandan,
Use this expression
{array}.map(x => {[x[โ@propertyTypeKeyโ]]: x.value})
Regards
Viktor
โ05-04-2022 01:33 AM
Hello @viktor_n , you rock!!! It is working, thank you so much for the help!
โ05-30-2022 09:49 AM
Hi @viktor_n and everyone,
When I tried the above expression.
I am getting response like below.
[{โActive_Flagโ: โYโ},{โData_flagโ:โNโ}, {โidโ:โ1โ} ]
[{โActive_Flagโ: โNโ},{โData_flagโ:โYโ}, {โidโ:โ2โ} ]
I wanted to flattened this records like below,
Id :1, Active_Flag: Y, Data_flag: N
Id :2, Active_Flag: N, Data_flag: Y
I tried json splitter it gives me whole array as flattened with no relation.
Can you please suggest me something.
thank you in advance!
โ05-30-2022 10:32 AM
For that to achieve, one approach is with the .reduce()
function.
Add this function at the end of the existing expression.
.reduce((acc, curr) => acc.extend(curr), {})