08-11-2021 01:06 PM
Hi there, I have this pipeline, that I am using to check for a path in Router snap and for somereason, cant make it work.
any pointer on what I am missing?
Basically I am looking for “E1EDPT2” in the json in my router, and I am using'E1EDPT2' in $
in my router. and it just ignores it says its missing.
[
{
"IDOC": {
"E1EDP01": [
{
"POSEX": "00010",
"E1EDPT1": {
"E1EDPT2": {
"TDLINE": "Line 10 First test"
}
}
},
{
"POSEX": "00020",
"E1EDPT1": {
"E1EDPT2": [
{
"TDLINE": "This is the second array text being sent."
},
{
"TDLINE": "This is the second line of second array text being sent"
}
]
}
}
]
}
}
][pipeline_2021_08_11 (2).slp|attachment](upload://oZ5dwsBjVnpLIMhkvhbreCtxi8k.slp) (6.9 KB)
Any help is greatly appreciated.
thanks
Manoharpipeline_2021_08_11 (2).slp (6.9 KB)
Solved! Go to Solution.
08-11-2021 03:34 PM
Yes, I presume so.
So you might change #3 to
jsonPath($,"$.IDOC.E1EDP01[?(@.hasPath('E1EDPT1') && @.E1EDPT1.hasPath('E1EDPT2'))]").length > 0
08-11-2021 02:28 PM
I don’t believe the “in” operator will do a deep object search without some creative expression coding.
.
There are probably a dozen ways to accomplish what you want, but based on the object structure you provided, here are optional expressions for your router.
'E1EDPT2' in $.IDOC.E1EDP01[0].E1EDPT1
jsonPath($,"$.IDOC.E1EDP01[?('E1EDPT2' in @.E1EDPT1)]").length > 0
jsonPath($,"$.IDOC.E1EDP01[?(@.E1EDPT1.hasPath('E1EDPT2'))]").length > 0
There are likely a number of other options that may be better suited depending on your overall input payload size and structure and potential overhead of the expression. But, hopefully these options will give you ideas to help you on your search.
Also, you probably want to select the “First match” checkbox in the router, otherwise, the documents will flow through to both outputs.
08-11-2021 02:40 PM
@del thanks for that.
One thing I forgot to mention, when E1EDPT2 is missing then its parent node, E1EDPT1, wont exist either.
if I go with 2 or 3, wont i will get error?
Thanks
Manohar
08-11-2021 03:34 PM
Yes, I presume so.
So you might change #3 to
jsonPath($,"$.IDOC.E1EDP01[?(@.hasPath('E1EDPT1') && @.E1EDPT1.hasPath('E1EDPT2'))]").length > 0
08-12-2021 07:04 AM
Thanks @del that did the trick.
Manohar