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