I have following method and i need to deserialize the retrieve stream.
  public void RedirectHyperlink(System.IO.Stream jsonString)
  {
       string val= JsonSteamToString(jsonString); 
  }
 public string JsonSteamToString(Stream jsonStream)
  {
       StreamReader reader = new StreamReader(jsonStream);
       return reader.ReadToEnd();
  }
My class is as follows:
 public class H2JsonStateObject
    {
        public string url { get; set; }
        public string stateId { get; set; }
    }
I'm calling this method using Ajax call as follows:
var value ="89aafdec-0a9e-4d05-b04e-1ca4bf8cfeb9";
var link="RedirectPage.aspx";
var data = '{"url":"' + link + '","stateId":"' + value + '"}';
var jsonToSend = JSON.stringify(data);
$.ajax({
    cache: false,
    url: "StateRedirectService.svc/RefreshPagemethod",
    type: "POST",
    async: false,
    data: jsonToSend,
    success: function (data, textStatus, jqXHR) {
        window.location.href = link;         
    },
    error: function (xhr, status, error) {
        alert('error');
    }
});
When the request receive to web method and after converting the value it get following string.
"\"{\\\"url\\\":\\\"RedirectPage.aspx\\\",\\\"stateId\\\":\\\"89aafdec-0a9e-4d05-b04e-1ca4bf8cfeb9\\\"}\"" 
Now i need to deserialize url & stateId. How can i do that?
I tried followings. but couldn't able to deserialize.
Using DataContractJsonSerializer
 using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(val)))
 {
       DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(H2JsonStateObject));
       H2JsonStateObject p2 = (H2JsonStateObject)deserializer.ReadObject(ms);
 }
It throws exception and says : Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''.
Using JavaScriptSerializer
  var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
  Object obj = serializer.DeserializeObject(val);
This gives me my object as string value as follows:
"{\"url\":\"RedirectPage.aspx\",\"stateId\":\"89aafdec-0a9e-4d05-b04e-1ca4bf8cfeb9\"}"
What I did wrong and how can i get RedirectPage.aspx and 89aafdec-0a9e-4d05-b04e-1ca4bf8cfeb9 value?