cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Reading JSON Format

amit_saroha
New Contributor III

Hi,

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_โ€)

[

{

"Content_ID":

"EBSPERSON_547229"

}

{

"Content_ID":

"EBSPERSONAD_547229"

}

{

"Content_ID":

"EBSPHONE_547229"

}

]
18 REPLIES 18

amit_saroha
New Contributor III

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

@amit.saroha
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']")

image

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

amit_saroha
New Contributor III

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

image

โ€œerrorโ€:

โ€œInvalidยทJSON-path:ยท$[?(value[โ€˜ns0:IntegrationNameโ€™]==โ€˜EBSPERSONโ€™)][โ€˜ns0:ContentIdโ€™]โ€

โ€œstacktraceโ€:

โ€œcom.snaplogic.common.jsonpath.InvalidPathException:ยทInvalidยทaccessorยท(http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/)ยทinยทpath:ยทcom.snaplogic.snap.api.ExpressionLocation@708cedde\r\nโ€”atยทcom.snaplogic.expression.JsonPathExpressionService.evaluate(JsonPathExpressionService.java:119)\r\nโ€”atยทcom.snaplogic.jsonpath.PathWalker.evaluate(PathWalker.java:167)\r\nโ€”atยทcom.snaplogic.jsonpath.tokens.FilterToken.testMember(FilterToken.java:57)\r\nโ€”atยทcom.snaplogic.jsonpath.tokens.FilterToken.traverse(FilterToken.java:71)\r\nโ€”atยทcom.snaplogic.jsonpath.tokens.SubscriptToken.traverse(SubscriptToken.java:51)\r\nโ€”atยทcom.snaplogic.jsonpath.PathWalker.traverse(PathWalker.java:402)\r\nโ€”atยทcom.snaplogic.jsonpath.PathWalker.traverse(PathWalker.java:462)\r\nโ€”atยทcom.snaplogic.jsonpath.JsonPathImpl.read(JsonPathImpl.java:138)\r\nโ€”atยทsl.EvaluatorUtils.jsonPathRead(EvaluatorUtils.java:697)\r\nโ€”atยทcom.snaplogic.expression.GlobalScope$JsonPathFunction.eval(GlobalScope.java:302)\r\nโ€”atยทsl.EvaluatorUtils.callFunction(EvaluatorUtils.java:760)\r\nโ€”atยทSC.evaluate(UnknownยทSource)\r\nโ€”atยทcom.snaplogic.util.ExpressionUtils$MyExpressionProperty.eval(ExpressionUtils.java:281)\r\nโ€”atยทcom.snaplogic.snap.api.impl.PropertyValuesImpl$ValidatingExpressionProperty.eval(PropertyValuesImpl.java:1005)\r\nโ€”atยทcom.snaplogic.snaps.transform.DataTransform.processBinary(DataTransform.java:263)\r\nโ€”atยทcom.snaplogic.snaps.transform.DataTransform.process(DataTransform.java:216)\r\nโ€”atยทcom.snaplogic.snap.api.ExecutionUtil.process(ExecutionUtil.java:106)\r\nโ€”atยทcom.snaplogic.snap.api.ExecutionUtil.executeForDocument(ExecutionUtil.java:118)\r\nโ€”atยทcom.snaplogic.snap.api.ExecutionUtil.execute(ExecutionUtil.java:81)\r\nโ€”atยทcom.snaplogic.snap.api.SimpleSnap.execute(SimpleSnap.java:70)\r\nโ€”atยทcom.snaplogic.cc.snap.common.SnapRunnableImpl.executeSnap(SnapRunnableImpl.java:800)\r\nโ€”atยทcom.snaplogic.cc.snap.common.SnapRunnableImpl.executeForSuggest(SnapRunnableImpl.java:647)\r\nโ€”atยทcom.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:856)\r\nโ€”atยทcom.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:435)\r\nโ€”atยทcom.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:117)\r\nโ€”atยทjava.base/java.util.concurrent.FutureTask.run(UnknownยทSource)\r\nโ€”atยทjava.base/java.util.concurrent.Executors$RunnableAdapter.call(UnknownยทSource)\r\nโ€”atยทjava.base/java.util.concurrent.FutureTask.run(UnknownยทSource)\r\nโ€”atยทjava.base/java.util.concurrent.ThreadPoolExecutor.runWorker(UnknownยทSource)\r\nโ€”atยทjava.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownยทSource)\r\nโ€”atยทjava.base/java.lang.Thread.run(UnknownยทSource)\r\nCausedยทby:ยทcom.snaplogic.snap.api.SnapDataException:ยทInvalidยทaccessorยท(http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/)ยทinยทpath:ยทcom.snaplogic.snap.api.ExpressionLocation@708cedde\r\nโ€”atยทsl.EvaluatorUtils.indexSuffix(EvaluatorUtils.java:1411)\r\nโ€”atยทSC.evaluate(UnknownยทSource)\r\nโ€”atยทcom.snaplogic.expression.JsonPathExpressionService.evaluate(JsonPathExpressionService.java:117)\r\nโ€”โ€ฆยท30ยทmore\r\nโ€

โ€œreasonโ€:

โ€œInvalidยทaccessorยท(http://xmlns.oracle.com/apps/hcm/processFlows/core/flowActionsService/types/)ยทinยทpath:ยทcom.snaplogic.snap.api.ExpressionLocation@708ceddeโ€

โ€œresolutionโ€:

โ€œPleaseยทcheckยทexpressionยทsyntaxยทandยทdataยทtypes.โ€

โ€œstatus_codeโ€:

โ€œerrorโ€

bojanvelevski
Valued Contributor

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:

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