Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Currently your web method return a <code>String</code> together with <code>ResponseFormat = WebMessageFormat.Json</code>. It follow to the JSON encoding of the string. Corresponds to www.json.org all double quotes in the string will be escaped using backslash. So you have currently double JSON encoding.</p> <p>The easiest way to return any kind of data is to change the output type of <code>GetCurrentCart()</code> web method to <code>Stream</code> or <code>Message</code> (from <code>System.ServiceModel.Channels</code>) instead of <code>String</code>.<br> See <a href="http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx" rel="noreferrer">http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx</a>, <a href="http://msdn.microsoft.com/en-us/library/ms789010.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms789010.aspx</a> and <a href="http://msdn.microsoft.com/en-us/library/cc681221(VS.90).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/cc681221(VS.90).aspx</a> for code examples.</p> <p>Because you don't wrote in your question which version of .NET you use, I suggest you to use an universal and the easiest way:</p> <pre><code>public Stream GetCurrentCart() { //Code ommited 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)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload