Reading JSON Format


How I can use an expression to read the below in a mapper to get individual values true or false? I am using as - $DocumentId.startsWith(“EBSPERSON_”)















Below is the actual data and I want to pass the value “EBSPERSON_547229” in the target path.

Use below expression :

jsonPath($, "$_Document_ID[?(value.Content_ID.startsWith('EBSPERSON_'))].Content_ID")

Thanks, @Dheeraj - But it didn’t work :frowning:

I see your JSON is not formatted properly. I would recommend validating the JSON snippet using some external validators
You can also attach your pipeline here and I can look into that

HCM Insert Person Records_2022_06_28.slp (65.9 KB)
@Dheeraj - I have attached the pipeline.

I won’t be able to validate your pipeline as it needs accounts to connect to the systems. In scenarios like this, it would be great if you can export the data to a JSON generator snap and work on the expressions it would be a lot simpler and easier to debug.

I am attaching a sample pipeline where I tried to replicate your data and worked on the expression.
Test Expr - Community_2022_06_28.slp (3.6 KB)

@Dheeraj , thanks for your help but the sample data is not like the way I have. I have the below data coming out of mapper -


In the another mapper when I use it the below error comes -

I just want the value from this like shown below -

I have uploaded the JSON file as well id someone wants to give it a try.

Mapper1_output0.json (144 Bytes)

Hope this helps

jsonPath($, "$[?(value.Document_ID.startsWith('EBSPERSON_'))].Document_ID")

The idea is to use the filter operator. It will select all the element/s in the Array that match the given expression. In the above example, my filter condition is based on the value of ‘Document_ID’


@Dheeraj - Thank you for all the help but I am still facing the issue. I think it’s not JSON in Document_ID but it is string (see screenshot # 2). Could you suggest how to overcome it?


Would you be able to download and share the preview of the upstream snap connected to the mapper snap(labeled
‘Person File’) shared in the screenshot above

Thank you, @Dheeraj for your help.

I have uploaded the output of the previous 3 snaps.


Mapper1_output0 (1).json (144 Bytes)
JSON_Splitter output0.json (1.3 KB)
Call_getIntegrationContentId output0.json (3.4 KB)

Thanks, Amit

If i understand your requirement, you are trying to get the highlighted section from the below API response

So, your output from the mapper should be ‘EBSPERSON_550542’ right ?

@Dheeraj - Yes, this is exactly what I am looking for.

I have copied the JSON Splitter to a JSON Generator snap and the following expressions works fine in a mapper

jsonPath($, "$[?(value['ns0:IntegrationName']=='EBSPERSON')]['ns0:ContentId']")

Also, attaching the pipeline just in case you need it for reference
Test Expr - Community_2022_06_29.slp (4.9 KB)

@Dheeraj , Thanks again for your help but it does not seems working when I placed the same expression in the mapper for me.











Per my understanding, you need to get the fields out of objects in array, that their value starts with “EBSPERSON_”. If that’s so, try the following expression:

$>x.filter((v,k)=> v.startsWith('EBSPERSONAD_')))

1 Like