title: c# read json from httpWebResponse
body: <p>I'm getting a json from <code>httpWebResponse</code> which supposed to be in the following format : </p>
  
  <pre><code>{"d":"{\"Success\":\"\",\"PricedItineraries\":[{\"IsRecommendedFlight\":false,\"BookingClass\":null,\"AirItinerary\":{\"OriginDestinationOptions\":{\"OriginDestinationOption\":[{\"FlightSegment\":[{\"DepartureAirport\":{\"LocationCode\":\"RAK\",\"Terminal\":\"1\"},\"ArrivalAirport\":{\"LocationCode\":\"ORY\",\"Terminal\":\"S\"},\"Equipment\":{\"AirEquipType\":\"73H\",\"ChangeofGauge\":\"true\"},\"MarketingAirline\":{\"Code\":\"TO\",\"CodeContext\":\"KBATO\"},\"OperatingAirline\":{\"Code\":\"TO\"},\"BookingClassAvails\":[{\"ResBookDesigCode\":\"A\",\"RPH\":\"5\"}],\"BagAllownceInfo\":{\"Allowance\":\"00\",\"QuantityCode\":\" N\",\"UnitQualifier\":\" K\"},\"FareID\":\"000000000\",\"Token\":\"00000000-0000-0000-0000-000000000000\",\"AdultBaseFare\":\"0000517.77\",\"AdultTaxFare\":\"0000000.00\",\"ChildBaseFare\":\"0000000.00\",\"ChildTaxFare\":\"0000000.00\",\"InfantBaseFare\":\"0000000.00\",\"InfantTaxFare\":\"0000000.00\",\"PriceTotal\":\"0000307.90\",\"LFID\":\"0000000\",\"PFID\":\"00000\",\"PTFID\":\"
  </code></pre>
  
  <p>I tried to <code>Deserialize</code> the json using <code>JSonConverter</code> but it returns stream was not readable:</p>
  
  <pre><code>public static object DeserializeFromStream(Stream stream)
  {
      var serializer = new JsonSerializer();
  
      using (var sr = new StreamReader(stream))
      using (var jsonTextReader = new JsonTextReader(sr))
      {
          return serializer.Deserialize(jsonTextReader);
      }
  }
  </code></pre>
  
  <p>So I'm reading my <code>httpwebresponse</code>: </p>
  
  <pre><code>using (StreamReader Reader = new StreamReader(ResStream))
  {
      this.ResponseHTML = Reader.ReadToEnd();
  }
  </code></pre>
  
  <p>But somehow it returns:</p>
  
  <pre><code>?W?S???"??yE,?????♣*Ay◄?lA+??F◄K?\?b;^~§????xN?yU,6U,?☺♣U,T??O?♠V►R?B§??*????↨??
  e?-|T?P?b???s§???M§♂U,?'??*?^le?????▬????§%7↕???f??Qd←|?c♣??
  bq7;???ffv%)?▬??↔L6???s?V?~?#?$♀]☺◄????D????'X?e?_?????"??E??Q]E,Ad-?   ♥?Xb'??K
  [???y;?d"0??:?-X??←Xòs←▬?→?$?↑-b☼}E,???"??MF??j↨??;vb)?aq?ai???R?.5,???????→▬jX?
  ♂5,?↑j??P?2?→?????+5,?tu?#??ev??☺7;???o☺??3w???P?B
  w???E?4!?→??MF??j??v?→▬?→???]jX?I?R???⌂?i]?5,a↕☼↓????→▬???kX??mjX?a◄1?♥'P?;??(??
  ♂??????H?aq??→▬??↑e???[§???%M?.^??}X???z??t??an?→▬c????_~Z?→▬jX?a?gZ?→▬jX?a?????
  ♂5,?↑j??P?2?→▬?a)Y??a????&gt;,
  5,??a?P?Ro▼▬?→???]jX?I????%t-jX8K?→▬jXLI?a?,!jX??%??PO??P?R?f???↔/4?f?c?7;?jX6?L
  </code></pre>
  
  <p>I'm sending the webrequest : </p>
  
  <pre><code> public Response Send()
          {
              if (REQUEST == null)
                  return new Response(REQUEST) { HTTPStatusCode = "999" }; 
  
              WebResponse Res = null;
              CookieContainer Cookies = new CookieContainer();
              if (REQUEST.Cookies != null)
              {
                  Cookies = REQUEST.Cookies;
              }
              bool isdone = true;
              DateTime Time = default(DateTime);
              Sender = (HttpWebRequest)WebRequest.Create(this.REQUEST._url);
              Sender.Host = REQUEST.Host;
              Sender.Accept = REQUEST.Accept;
              Sender.Method = REQUEST.Method;
              Sender.UserAgent = REQUEST.UserAgent;
              Sender.ContentType = REQUEST.ContentType;
              Sender.CookieContainer = Cookies;
              Sender.Referer = REQUEST.Refer;
  
              if (REQUEST.Data != null &amp;&amp; REQUEST.Data.Length &gt; 0)
              {
                  using (var writer = new StreamWriter(Sender.GetRequestStream()))
                  {
                      writer.Write(REQUEST.Data);
                      writer.Flush();
                      writer.Close();
                  }
              }
  
              try
              {
                  Res = Sender.GetResponse();
                  Time = DateTime.Now;
              }
              catch (Exception Ex)
              {
                  isdone = false;
                  if (OnExceptionHappened != null)
                      OnExceptionHappened(this, new ExceptionArgs { Msg = Ex.Message, Sender = this, Time = DateTime.Now });
              }
  
              return AssignWebResponse((HttpWebResponse)Res, isdone, Time, Cookies, Sender.RequestUri.AbsoluteUri);
          }
  </code></pre>
  
  <p>Request : </p>
  
  <pre><code>        var REQUEST = new Request()
          {
              _url = "https://www.example.com/",
              Host = "host",
              Method = "POST",
              Refer = "refer",
              UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0",
              ContentType = "application/json",
              Cookies = CurrentContainer,
              Data = "{ 'isFromCache': 'undefined', 'pageNumber': '1'}",
              isJson = true
          };
          using (BeRequest.CORE.BeRequest Req = new BeRequest.CORE.BeRequest(REQUEST))
          {
              Req.OnExceptionHappened += Req_OnExceptionHappened;
              var response = Req.Send();
  
              return response.ResponseHTML;
          }
  </code></pre>