JavaScriptSerializer.deserialize

Last post 07-23-2008 4:33 PM by earth533. 4 replies.

Sort Posts:

  • JavaScriptSerializer.deserialize

    07-23-2008, 3:12 PM
    • Loading...
    • earth533
    • Joined on 07-23-2008, 1:27 PM
    • Posts 3

     HI

    I am serializing to a JSON object using

     JavaScriptSerializer js = new JavaScriptSerializer();
     HttpContext.Current.Response.ContentType = "application/json";
     HttpContext.Current.Response.Write(js.Serialize(response));

    response is of Class

    public class Response
        {
            public bool success;
            public int id;
            public string error;
          
        }

     and in my JavaScript file I am deserializing

    using

    var sResponse = Sys.Serialization.JavaScriptSerializer.deserialize(response); 

    For IE and Safari  response is properly deserialized.

    But for firefox it says The data doesnt correspond to a valid JSON.


     

  • Re: JavaScriptSerializer.deserialize doesnt doesnt work on FireFox but works fine on IE and safari

    07-23-2008, 3:23 PM
    • Loading...
    • tommyk
    • Joined on 07-11-2007, 6:18 PM
    • Columbus Ohio
    • Posts 18

     What is your json string? 

     

    I have a feeling that since your not clearing your response, that maybe some other text is coming back with the json which is screwing it up

    Tommy
  • Re: JavaScriptSerializer.deserialize doesnt doesnt work on FireFox but works fine on IE and safari

    07-23-2008, 3:36 PM
    • Loading...
    • earth533
    • Joined on 07-23-2008, 1:27 PM
    • Posts 3

     this is my string {"success":true,"id":5733012,"error":""}

    I tested in FF 3.0.1 and it works but doesnt work on FF 2.0.0.16 . Is this a known FF bug ?

  • Re: JavaScriptSerializer.deserialize doesnt doesnt work on FireFox but works fine on IE and safari

    07-23-2008, 3:49 PM
    • Loading...
    • tommyk
    • Joined on 07-11-2007, 6:18 PM
    • Columbus Ohio
    • Posts 18

     are you running the latest version of ASP.Net Ajax?

    Tommy
  • Re: JavaScriptSerializer.deserialize doesnt doesnt work on FireFox but works fine on IE and safari

    07-23-2008, 4:33 PM
    • Loading...
    • earth533
    • Joined on 07-23-2008, 1:27 PM
    • Posts 3

      version - 1.0.61025.0

     

     

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter