Getting back slash in json format response from Rest service

I am getting these type of response from rest resvice
{
“ProfileStatus”: "{“Status”:“SUCCESS”}
}

how to remove this?

In your post " is missing, is the json response is as below? then its a valid json, you can parse the json string. Let me know your expected output response.

Provide details about the rest service? or you a provider/consumer?

{
“ProfileStatus”: “{“Status”:“SUCCESS”}”
}

1 Like

I am the rest service provide when i tried to consume my service from post man i got response in below format
{
“ProfileStatus”: “{“Status”:“SUCCESS”}”
}

Application which consumes this service facing issue because this escape character.is there any way i can remove the backslash?
who should parse the json string ESB or consumer application?

I am the provider.when i try to consume the service from post man i got the below response
{
“ProfileStatus”: “{“Status”:“SUCCESS”}”
}

the application which consumes my service facing issue bcoz of this escape character.they even tried parsing this json string it doesn’t help it seems. is there a way i can remove this?
or any other way i could send this json response?

I would like to have a look at your provider rest service, can you copy the flow service (that returns the “ProfileStatus” in a sample package.

Even you can trace through the service and find out the output vairables in the pipeline.

Is the response supposed to be this?

{
“ProfileStatus”: {
“Status”: “SUCCESS”
}
}

If so, then it is likely that your service is incorrectly converting a Status document to a JSON string, then assigning that string as the value for ProfileStatus.

If the string above is what you’re after, then create an IS document that has Status as a nested field within ProfileStatus. Assign the “SUCCESS” value to Status, then convert the ProfileStatus document to a JSON string. You only need to convert the top-level document.

Vignesh,

Already posted solutions are perfect but if you are simply looking to replace the backslash before returning response to your consumer, you can do pub.string:replace and set useRegex as true. Pass in the searchString as \. This way you escape the backslash.

Regards,
Ashish Bania

I strongly advise against using replace in this case. Using regex to edit JSON is a precursor to future problems.