Using the Filter Snap on nested array
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.
jfpelletier - assuming this input document:
{"ids":["r4ige6rwgvnr","4nkmdoijydfj9","6ashbd99w3"]}
Configure a Mapper expression as follows:
Should provide the desired output. Take a look at the Array.map() documentation for description. The Javascript documentation linked in the SnapLogic documentation has some excellent details and examples. Basically the statement shown above is turning each string value in the array to an object.