cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch value from array?

Manigandan
New Contributor II

Hello Team,

I have the below array and I need to fetch the filename where active=1. Please can you help me on this.

“array” : [
{
“active”: 0,
“fileName”: “test.pdf”
},
{
“active”: 1,
“fileName”: “test1.pdf”
}
]

Thanks in advance!

2 REPLIES 2

marjan_karafilo
Contributor

Hi @Manigandan ,

You can use the Filter snap to filter out only active objects.

Please take a look at the attached pipeline.

00_Fetch_Active_2023_07_16.slp (4.6 KB)

Best regards,
Marjan

Hi @Manigandan,

@marjan.karafiloski’s solution will help you in this case.
If you want to keep everything in one mapper, then take a look at the array filter function:

Filter array

The expression would look something like this:

$array.filter(x=>x.active == 1)

Regards,
Bojan