title: Deserializing JSON from Controller to AJAX Success
body: <p>I am having trouble finding the right format of using a <code>HttpWebRequest</code>, and returning its response into readable <code>JSON</code> for a Javascript AJAX function.</p>
  
  <p>If I return just <code>text</code>, it adds escaping slashes to the response. If I deserialize <code>text</code> it then add's all the indentation and makes it unreadable by my Javascript. (I think because it is not passing an actual object either)</p>
  
  <p>Just trying to pass a readable json object to my ajax.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult teamLookUp(string ID)
  {
      HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("someurl.com/apis");
      myReq.ContentType = "application/json; charset=utf-8";
      var response = (HttpWebResponse)myReq.GetResponse();
      string text;
  
      using (var sr = new StreamReader(response.GetResponseStream()))
      {
          text = sr.ReadToEnd();
      }
  
      var json2 = JsonConvert.DeserializeObject(text);
      return Json(new { json = json2 });
  
      // return Json(new {json = text}); returns json with escaping \'s 
      //     i.e. "json":"{\"item":\"item2"}
      // return Json(new {json = json2}); returns empty json, 
      //     i.e. {"json":[[],[],[],[]]}
  }
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code> $.ajax({
          url: "/Competitive/teamLookUp",
          type: "POST",
          data: "ID=" + ID,
          success: function (json) {
              alert(JSON.stringify(json));
              alert(json[ID].name());
          }, 
          error: function(error) {
          }
     });
  </code></pre>
  
  <p>Need help with returning <code>json object</code> back to my AJAX success function.</p>