Prevent REST response from being escaped

rlatorre
Kilo Sage

I have a scripted web service is is generating a JSON formatted string. When sent as the response it is being escaped. How can this be prevented?

Output when run in background script:

{"number": "INC0939032","short_description":"Title text","description":"Description text",....

Output from the REST service:

{\"number\":\"INC0832852\",\"short_description\":\"Title text\",\"description\":\"Description text",....

Requirement:

We need to supply a list of fields and all related comments from and Incident in a single JSON formatted response.

Any assistance will be appreciated.

1 ACCEPTED SOLUTION

Liju John1
Mega Guru

try this .


var httpResp = JSON.stringify(JSON.parse(response.getBody()));


gs.log("REST httpResponse : " + httpResp);


-------------------------------------------------------------------------------------------------



*** Script: REST httpResponse : {"offsets":[{"partition":0,"offset":15938347,"error_code":null,"error":null},{"partition":0,"offset":


find_real_file.png


*Please mark as Helpful or Correct Answer if this was useful.


View solution in original post

5 REPLIES 5