06-28-2022 10:43 AM
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"
}
]
06-29-2022 09:35 AM
@Dheeraj - Yes, this is exactly what I am looking for.
06-29-2022 09:51 AM
@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']")
Also, attaching the pipeline just in case you need it for reference
Test Expr - Community_2022_06_29.slp (4.9 KB)
06-29-2022 10:19 AM
@Dheeraj , Thanks again for your help but it does not seems working when I placed the same expression in the mapper for me.
“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”
06-30-2022 12:38 AM
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_')))