Currently your web method returns a String together with ResponseFormat = WebMessageFormat.Json. It follows that your code will use the JSON encoding of the string. Corresponding to json.org, this means all double quotes in the string will be escaped using backslashes. So you currently have double JSON encoding.
The easiest way to return any kind of data is to change the output type of the GetCurrentCart() web method to Stream or Message (from System.ServiceModel.Channels) instead of String.
For code examples, see also…
- Carlos Figueira MSDN blog post, ‘WCF “Raw” programming model’,
- MSDN’s “How to: Enable Streaming”, and
- MSDN’s “How to: Create a Service That Returns Arbitrary Data Using The WCF REST Programming Model”.
Because you don’t include in your question which version of .NET you use, I suggest you to use a universal (and the easiest) way:
public Stream GetCurrentCart()
{
//Code ommitted
var j = new { Content = response.Content, Display=response.Display,
SubTotal=response.SubTotal};
var s = new JavaScriptSerializer();
string jsonClient = s.Serialize(j);
WebOperationContext.Current.OutgoingResponse.ContentType =
"application/json; charset=utf-8";
return new MemoryStream(Encoding.UTF8.GetBytes(jsonClient));
}