I use a REST Apex service and return String from the method. The client call to the REST API returns with qoutes around the reqult like this example: "…result.." and also with \" inside the result.How do I get rid of the quotes ? I saw Pat's blog about using Blob.valueOf(..) but I want to return a JSONObject like a String as you would do in Jersey.
@HttpGet
global static String getAllEmployeeDataForContact() {
return JSON.serialize(.....)
TIA
Best Answer
Quotes will come anyway, you don't need to use JSON.serialise with Apex web REST services, they take care of format XML/JSON automatically, so returning the type directly would work. Here is the sample, that I tried and is working fine.
Result is coming with double quotes as you said and its correct as well
But this is not a JSON string actually try converting it to some wrapped type for easy consumption by clients like
This returns a JSON string like this
Hope this helps.