cancel
Showing results for 
Search instead for 
Did you mean: 

Filter in the array

kachanta
New Contributor

Hello Community,
I have been trying hard to build a logic urgently. I’m requesting SnapLogic expression language experts to assist here.

I have the input data like below and need to get the phone “number” filed validating 3 conditions.

  1. Type should be ‘Mobile’ in array “phone”
  2. type should be == ‘Voice’ inside the array “utilizationMeanings”
  3. endDate field should be null which is inside another array “dates” inside “utilizationMeanings”

To detail: $ phones[ < find type = Mobile >].utilizationMeanings[ < find type= voice >].dates[< find endDate ==null>].number

{
“phone”: [
{
“number”: “123456789”,
“type”: “Mobile”,
“utilizationMeanings”: [
{ “type”: “Voice”,
“dates”: [
{“startDate”: “2023-05-31T12:08:47.503Z”,“endDate”: null }
]
},
{
“type”: “Text”,
“dates”: [
{“startDate”: “2023-05-30T00:00:00”, “endDate”: null }
]
}
]
}
]
}

5 REPLIES 5

Abhishek_Soni37
Contributor

Hi @kachanta

Try this expression: You can find more details on jsonPath here.
image

Pipeline:
NumberValidation_Using_JSONPATH.slp (3.9 KB)

I hope this helps 🙂

Cheers

kachanta
New Contributor

Here we have hardcoded [0] which brings only first element, but there are multiple elements in each array. We need to filter 1 based on the value matching.

It would be a great help if someone could help me on this.
Ideas please…

Can you share sample input with multiple items?