title: Parsing JSON returned from ASP.Net in Javascript
body: <p>I am trying to map the coordinates of the following JSON text on a Mapquest Map by calling an ASP.net method that returns this string, but I am unable to figure out how to extract the latitude and longitude from it.  </p>
  
  <p><code>
  {"d":"{\"results\":[{\"fullName\":\"Albert Pinto\",\"callType\":\"Other - See Comments\",\"comments\":\"He was not happy with our dealer\u0027 s service. Had to be pacified.\",\"geolatitude\":38.9661791,\"geolongitude\":-94.7185354,\"geolocation\":\"{\\\"places\\\":[{\\\"street1\\\":\\\"Bond St\\\",\\\"postalCode\\\":\\\"66214\\\",\\\"address\\\":\\\"8951 Bond St, Overland Park, KS  66214, , United States\\\",\\\"displayAddress\\\":\\\"8951 Bond St, Overland Park, KS  66214, , United States\\\",\\\"street\\\":\\\"Bond St\\\",\\\"countryCode\\\":\\\"US\\\",\\\"region2\\\":\\\"\\\",\\\"longitude\\\":\\\"-94.718535\\\",\\\"region1\\\":\\\"\\\",\\\"latitude\\\":\\\"38.966179\\\",\\\"country_code\\\":\\\"US\\\",\\\"country\\\":\\\"United States\\\",\\\"city\\\":\\\"Overland Park\\\"}],\\\"source\\\":{\\\"locationServicesEnabled\\\":true,\\\"hasCompass\\\":true,\\\"purpose\\\":\\\"Get Current Location\\\"},\\\"success\\\":true}\",\"address\":\"8951 Bond St, Overland Park, KS  66214, , United States\",\"createdAt\":\"2012-01-18T05:57:58.923Z\",\"updatedAt\":\"2012-01-18T05:57:58.923Z\",\"objectId\":\"cqJK1nF1sB\"}]}"}
  </code>  </p>
  
  <p>I have googled for hours and tried several different approach (trying to return just a Lat/Long array from asp.net, trying to parse JSON using JQuery) but my limited knowledge of JavaScript seems to hinder any progress.</p>
  
  <p>Any help or pointers will be greatly appreciated. Here is how my JavaScript looks like so far....</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  
              MQA.EventUtil.observe(window, 'load', function () {
  
                  $.ajax({
                      url: "Default.aspx/SendAnSMSMessage",   // This method returns the JSON string
                      type: "POST", // data has to be POSTed
                      contentType: "application/json", // posting JSON content    
                      dataType: "text",
                      //dataType: "JSON",  // type of data is JSON (must be upper case!)
                      timeout: 10000,    // AJAX timeout
                      success: function (result) {
                          console.log(result.toString()); //The JSON string is copied from the console here..
                          alert(result);
  
  //NOT SURE WHAT TO DO NEXT HERE TO EXTRACT LAT/LONG.
  
                          /*Create a new POI collection.*/
                          var sc = new MQA.ShapeCollection(), poi, latlng = { lat: 39.0, lng: -82.0 }, i;
  
                          /*Create additional POIs and add them to the shape collection.*/
                          for (i = 0; i &lt; 5; i++) {
                              latlng.lat = latlng.lat + 0.01;
                              latlng.lng = latlng.lng - 0.01;
  
                              poi = new MQA.Poi(latlng);
                              sc.add(poi);
                          }
  
                          /*Construct an instance of MQA.TileMap with the shape collection in the map constructor.*/
                          window.map = new MQA.TileMap({
                              elt: document.getElementById('map'),
                              collection: sc,
                              bestFitMargin: 100
                          });
  
  
                      },
                      error: function (xhr, status) {
                          alert(status + " - " + xhr.responseText);
                      }
                  });
  
              });
  
          &lt;/script&gt;
  </code></pre>
  
  <p>Here is the ASP.Net code that calls the REST API.</p>
  
  <pre><code>[WebMethod] public static string SendAnSMSMessage() 
  { 
  var httpWebRequest = (HttpWebRequest)WebRequest.Create("//myurl"); 
  httpWebRequest.ContentType = "application/json";
  httpWebRequest.Credentials = new NetworkCredential("name", "pwd"); 
  httpWebRequest.Method = "GET"; 
  var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); 
  using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) 
  {
  var responseText = streamReader.ReadToEnd(); 
  return responseText;} 
  }
  </code></pre>