Forum Discussion
10 Replies
- swrightNew Contributor III
I had tried these before and I think that they should have worked but they didn’t.
The first one changed the values to 1 and 2 which isn’t what I want:
$[‘env:Envelope’][‘env:Body’][‘ns0:uploadFileToUcmResponse’].result[‘$’][1]
The second one failed with:
reason":
“‘1’ was not found while evaluating the sub-expression ‘$[‘env:Envelope’][‘env:Body’][‘ns0:uploadFileToUcmResponse’].result[1]’”
I also tried the following that failed:
$[‘env:Envelope’][‘env:Body’][‘ns0:uploadFileToUcmResponse’].result[‘$’].pop()
It failed with:
"String type does not have a method named: pop, found in: …sult[‘$’].pop().
Thanks,
Scott
- swrightNew Contributor III
I attached a copy of the json.
I am currently using a fix for the issue in which I use a filter snap after the mapper. It works, but I think that I should be able to select from the values in the mapper and not have to use the filter. Although it looked to me like an array, it seems to be a string which is why many of the things I tried didn’t work.
Thanks,
Scott
(Attachment Copy_output0.json is missing)
- swrightNew Contributor III
Sorry. My attachment didn’t get through due to a .json extension. I’m sending it now after change the extension to .txt.
Copy_output0.txt (3.56 KB)
- ptaylorEmployee
You are dealing with 2 separate input documents. The Mapper gets these one-by-one, not both of them at once.
Assuming the Mapper’s input is coming from a Json Parser, you can deal with this by unchecking “Process array” in the Json Parser settings. Then the Mapper will receive a single document whose root is an array. Then your expression would look like this:
jsonPath($, "$[*]['env:Envelope']['env:Body']['ns0:uploadFileToUcmResponse'].result['$']")[1]
Another approach is to filter the Mapper’s input so that you’re only getting the second document. To do that, insert a Head snap with an offset of 1.
- skatpallyFormer Employee
One more way of doing is use a Group By Snap and use the below Expression.
jsonPath($, “$group[?(value[‘env:Envelope’][‘env:Body’][‘ns0:uploadFileToUcmResponse’].result[‘$’]==125044)]”)
sample_2020_10_29.slp (8.9 KB)