title: JSON Response Contains Extra Characters
body: <p>I created a service to do database lookup and return result as JSON, using Nancy. Here is test code:</p>
  
  <pre><code>using (var dt = new DataTable("MyData"))
  {
      dt.Columns.Add("id");
      dt.Columns.Add("password");
      dt.Columns.Add("body", System.Type.GetType("System.String"));
      dt.Columns.Add("balance", System.Type.GetType("System.Double"));
      dt.Rows.Add(uid, pwd, "Some useful content", 33.75);
      dt.Rows.Add(uid, pwd, "More useful content", 128.55);
      if (dotNetDataTable)
          json = JsonConvert.SerializeObject(dt, new Serialization.DataTableConverter());
      else
          json = JsonConvert.SerializeObject(dt);
      json = "{\"status\":\"success\",\"data\":" + json + "}";
      return Response.AsJson(json);
  }
  </code></pre>
  
  <p>Interrupting process just before return, and polling value of json, I get:</p>
  
  <pre><code>"{\"status\":\"success\",\"data\":[{\"id\":\"RMittelman\",\"password\":\"Password\",\"body\":\"Some useful content\",\"balance\":33.75},{\"id\":\"RMittelman\",\"password\":\"Password\",\"body\":\"More useful content\",\"balance\":128.55}]}"
  </code></pre>
  
  <p>This seems correct in immediate window.  When I receive data, and interrupt the process, I get this in the client immediate window:</p>
  
  <pre><code>"\"{\\\"status\\\":\\\"success\\\",\\\"data\\\":[{\\\"id\\\":\\\"RMittelman\\\",\\\"password\\\":\\\"Password\\\",\\\"body\\\":\\\"Some useful content\\\",\\\"balance\\\":33.75},{\\\"id\\\":\\\"RMittelman\\\",\\\"password\\\":\\\"Password\\\",\\\"body\\\":\\\"More useful content\\\",\\\"balance\\\":128.55}]}\""
  </code></pre>
  
  <p>Which as you can see contains extra leading and trailing quotes, and a bunch of extra backslashes.  The JSON will not deserialize. Here is the result shown in client's text box:</p>
  
  <pre><code>json result:
  "{\"status\":\"success\",\"data\":
  [{\"id\":\"RMittelman\",\"password\":\"Password\",\"body\":\"Some useful content\",\"balance\":33.75},
  {\"id\":\"RMittelman\",\"password\":\"Password\",\"body\":\"More useful content\",\"balance\":128.55}]}"
  
  Unexpected JSON token when reading DataTable. Expected StartArray, got String. Path '', line 1, position 240.
  </code></pre>
  
  <p>If I programmatically remove leading and trailing quotes, and all backslashes, it works fine.
  Here is the code I use in client to get the data:</p>
  
  <pre><code>string GET(string url)
  {
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
      try
      {
          WebResponse response = request.GetResponse();
          using (Stream responseStream = response.GetResponseStream())
          {
              StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
              string responseText = reader.ReadToEnd();
              isError = false;
              return responseText;
          }
      }
      catch (WebException ex)
      {
          isError = true;
          WebResponse errorResponse = ex.Response;
          if (errorResponse == null)
              return ex.Message;
          using (Stream responseStream = errorResponse.GetResponseStream())
          {
              StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
              String errorText = reader.ReadToEnd();
              return errorText;
          }
          throw;
      }
  }
  </code></pre>
  
  <p>So question is, why does it look ok before sending, but contain all the junk after sending?</p>