cancel
Showing results for 
Search instead for 
Did you mean: 

Using the Filter Snap on nested array

LanreOyewole
New Contributor II

I have a JSON payload with a nested array (below). I am trying to use the filter Snap to select specific items only. Unfortunately, the expressions that I have tried have not worked - they select everything or nothing.
$myList.filter(x => x.num==1)
$myList.filter(x => x.num==1)[0].num==1

[{"myList":[{"msg":"Hello, World1","num":1,"type":"Q"},{"msg":"Hello, World2","num":2,"type":"X"},{"msg":"Hello, World3","num":3,"type":"Q"}]}]

Any help or suggestions will be very much appreciated.

 

1 ACCEPTED SOLUTION

ivicakoteski
New Contributor III

Hi @LanreOyewole 

You can try the following expression in the mapper snap.

ivicakoteski_0-1691418485414.png


BR.
Ivica

View solution in original post

5 REPLIES 5

Thanks @koryknick, that is certainly what I have discovered - the docs don't mention this constraint though, which is why I spent so much time trying to get it to work 😀👍🏿

I have also noticed that expressions don't work well when one or more of the ancestor nodes is an array 🤔