cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch values from below array?

Manigandan
New Contributor II

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.

1 ACCEPTED SOLUTION

viktor_n
Contributor II

Hi @Manigandan,

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

Regards
Viktor

View solution in original post

4 REPLIES 4

viktor_n
Contributor II

Hi @Manigandan,

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

Regards
Viktor

Manigandan
New Contributor II

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

Manigandan
New Contributor II

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