I'm trying to consume JSON from target endpoint response, remove unwanted elements and returning a custom JSON payload to the client.
One of the elements in the JSON that I get from the target endpoint has /n and /r characters
"description": "Overview\r\n\r\nCurrent State -Some Text\r\n\r\n Some Other Text"
I extract "description" into a variable called descriptionFromTarget and create a new payload with the element called "myDescription"
<Payload contentType="application/json" variableSuffix="#" variablePrefix="@"> { "myDescription":"@descriptionFromTarget#", } </Payload>
The problem is that the /n and /r characters are not preserved but the string is converted to a multilne string. So myDescription looks like this
"Overview Current State -Some Text Some Other Text"
This of course is invalid format.
How do I preserve the /n and /r characters during the extraction and assignment so that the content is exactly like it is in the JSON response from target?
Solved! Go to Solution.
I ended using the javascript for extraction and creation of response by using the javascript callout. Much simpler.
Related Question
How do I preserve the URL coming form target ?
Here's what I get from target
https://mydomain.com/secure/attachment/79572/image-2018-05-14-16-39-27-484.png
But after extraction and assignment I get
"https: \/\/mydomain.com\/secure\/attachment\/79572\/image-2018-05-14-16-39-27-484.png"
I ended using the javascript for extraction and creation of response by using the javascript callout. Much simpler.
Just a footnote - you don't need the prefix and suffix.
you can convert this:
<Payload contentType="application/json" variableSuffix="#" variablePrefix="@"> { "myDescription":"@descriptionFromTarget#", } </Payload>
...to this:
<Payload contentType="application/json">{ "myDescription":"{descriptionFromTarget}" } </Payload>
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |