How to fetch values from below array?

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.

Hi @Manigandan,

Use this expression
{array}.map(x => {[x[‘@propertyTypeKey’]]: x.value})

Regards
Viktor

3 Likes

Hello @viktor_n , you rock!!! It is working, thank you so much for the help!

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!

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), {})