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

How to get only one of two items returned

swright
New Contributor III

In a mapper snap, my current expression is:
$[โ€˜env:Envelopeโ€™][โ€˜env:Bodyโ€™][โ€˜ns0:uploadFileToUcmResponseโ€™].result[โ€˜$โ€™]

I only want the second value โ€œ123109โ€ returned as a string. How can I do this? Thanks!

image

10 REPLIES 10

Supratim
Contributor III

@swright array[1] , it will give you 2nd value. for your case it looks like-

[โ€˜env:Envelopeโ€™][โ€˜env:Bodyโ€™][โ€˜ns0:uploadFileToUcmResponseโ€™].result[โ€˜$โ€™][1]
or
[โ€˜env:Envelopeโ€™][โ€˜env:Bodyโ€™][โ€˜ns0:uploadFileToUcmResponseโ€™].result[1]

swright
New 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

Supratim
Contributor III

@swright Is that possible to share sample json here?

swright
New 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.

image001.png

Thanks,

Scott

(Attachment Copy_output0.json is missing)