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?