title: JSON data returned from WCF service contains escape characters
body: <p>I have a working WCF - WPF application working, however I'm looking for some optimization.
  Below is my code where a WCF restful service is exposing a JSON array, and a WPF UI is receiving it without any problem.</p>
  
  <p>WCF: </p>
  
  <pre><code>public clsStatus[] GetAllStatus()
  {
  
      DataTable dt = new DataTable();
      List&lt;clsStatus&gt; lstGetAllStatus = new List&lt;clsStatus&gt;();
      try
      {
          dt = // My Data Table
  
          foreach (DataRow dr in dt.Rows)
          {
              dcStatus objGetAllStatus = new clsStatus();
              objGetAllStatus.Id = Convert.ToInt32(dr["Id"]);
              objGetAllStatus.Status = dr["Status"].ToString();                   
              lstGetAllStatus.Add(objGetAllStatus);
          }
  
      }
      return lstGetAllStatus.ToArray();
  }
  </code></pre>
  
  <p>In WPF UI:</p>
  
  <pre><code>public ObservableCollection&lt;T&gt; InvokeGet&lt;T&gt;(string sUrl)
  {
  
      System.Net.WebRequest request = System.Net.HttpWebRequest.Create(sUrl);
  
      request.Method = "GET";
  
      request.UseDefaultCredentials = true;
  
      request.ContentLength = 0;
  
      System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
  
      Stream objResponseStream = response.GetResponseStream();
  
      StreamReader reader = new StreamReader(objResponseStream);
  
      string objResponseString = reader.ReadToEnd();
  
      response.Close();
  
      JavaScriptSerializer objJsonserialiser = new JavaScriptSerializer();
  
      objJsonserialiser.MaxJsonLength = 999999999;
  
      T[] arrResult = objJsonserialiser.Deserialize&lt;T[]&gt;(objResponseString);
  
      return new ObservableCollection&lt;T&gt;(arrResult);  
  
  }
  </code></pre>
  
  <p>This way serialization/deserialization is working fine, whereas when I make the changes shown below the deserialization no longer works:</p>
  
  <p>In WCF:</p>
  
  <pre><code>public string[] GetAllStatus()
  {
      DataTable dt = new DataTable();
  
      try
      {
          dt = // My Data Table
  
          string jsonresp = JsonConvert.SerializeObject(dt, Formatting.None);
      }
  
      return jsonresp;
  }
  </code></pre>
  
  <p>In WPF: </p>
  
  <pre><code>public ObservableCollection&lt;T&gt; InvokeGet&lt;T&gt;(string sUrl )
  {
  
      System.Net.WebRequest request = System.Net.HttpWebRequest.Create(sUrl);
  
      request.Method = "GET";
  
      request.UseDefaultCredentials = true;
  
      request.ContentLength = 0;
  
      System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
  
      Stream objResponseStream = response.GetResponseStream();
  
      StreamReader reader = new StreamReader(objResponseStream);
  
      string objResponseString = reader.ReadToEnd();
  
      response.Close();
  
      dsReportRequests dsrepreq = new dsReportRequests();
  
      //This conversion is failing with error
      dsrepreq = JsonConvert.DeserializeObject&lt;dsReportRequests&gt;(objResponseString);
  }
  </code></pre>
  
  <p>Error:  <code>"Error converting value \"[{\"Id\":11280,\"statName}]\" to type 'clsStat[]'. Path '', line 1, position 759."</code></p>
  
  <p>I found out that the JSON format in the changed code contains escape chars (<code>\</code>), which seems to be causing the error while deserializing.</p>