.NET 3.5 version of code

Discussion in 'ASP .Net' started by Matty J, May 17, 2008.

  1. Matty J

    Matty J Guest

    Hi

    I'm having difficulty finding out what the latest version of the .NET
    framework's C# code equivalent is for the following:

    using System.Web.Script.Serialization;

    JavaScriptSerializer ser = new JavaScriptSerializer();
    result = ser.Deserialize<MyType>(JSON_encoded_string);


    Any help would be appreciated.
    Cheers
    Matt
     
    Matty J, May 17, 2008
    #1
    1. Advertising

  2. This should help you :

    http://msdn.microsoft.com/en-us/library/bb355316.aspx



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Matty J" <> wrote in message
    news:...
    > Hi
    >
    > I'm having difficulty finding out what the latest version of the .NET
    > framework's C# code equivalent is for the following:
    >
    > using System.Web.Script.Serialization;
    >
    > JavaScriptSerializer ser = new JavaScriptSerializer();
    > result = ser.Deserialize<MyType>(JSON_encoded_string);
    >
    >
    > Any help would be appreciated.
    > Cheers
    > Matt
     
    Juan T. Llibre, May 17, 2008
    #2
    1. Advertising

  3. Matty J

    Matty J Guest

    Thanks Juan.

    I'm confused - is that not the same code as in my example?

    When I compile my project using Visual Studio 2008 it tells me:
    Warning
    1 'System.Web.Script.Serialization.JavaScriptSerializer.JavaScriptSerializer()'
    is obsolete: 'The recommended alternative is
    System.Runtime.Serialization.DataContractJsonSerializer.' C:\inetpub
    \Website\members\default.aspx.cs 53 32 WebProject

    Any further ideas?
    Cheers
    Matt
     
    Matty J, May 20, 2008
    #3
  4. re:
    !> obsolete

    Obsolete ?

    Even ScottGu wonders why :

    http://weblogs.asp.net/scottgu/arch...-a-tojson-extension-method-using-net-3-5.aspx

    Read the sample code there, as well, as the user comments and Scott's replies.

    Also, note that "obsolete' doesn't mean you can't use it, even if you get a warning.

    <quote>
    The JavaScriptSerializer is currently marked obsolete - although I'm
    not sure why (was going to ask someone about this today). It is very handy.

    Note that obsolete doesn't mean removal in .NET 3.5
    - it will be supported at least another version or two (or longer if I can convince them <g>)
    </quote>

    Your code should work...with a warning.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Matty J" <> wrote in message
    news:...
    > Thanks Juan.
    >
    > I'm confused - is that not the same code as in my example?
    >
    > When I compile my project using Visual Studio 2008 it tells me:
    > Warning
    > 1 'System.Web.Script.Serialization.JavaScriptSerializer.JavaScriptSerializer()'
    > is obsolete: 'The recommended alternative is
    > System.Runtime.Serialization.DataContractJsonSerializer.' C:\inetpub
    > \Website\members\default.aspx.cs 53 32 WebProject
    >
    > Any further ideas?
    > Cheers
    > Matt
     
    Juan T. Llibre, May 20, 2008
    #4
  5. Matty J

    Matty J Guest

    Great, thanks Juan, that's what I needed to know.
    Cheers
    Matt
     
    Matty J, May 21, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shadow Lynx
    Replies:
    3
    Views:
    4,103
    Shadow Lynx
    Jan 30, 2006
  2. Replies:
    6
    Views:
    36,038
    tinvan
    Sep 21, 2006
  3. V Green
    Replies:
    0
    Views:
    925
    V Green
    Feb 5, 2008
  4. PA Bear [MS MVP]
    Replies:
    0
    Views:
    1,036
    PA Bear [MS MVP]
    Feb 5, 2008
  5. MowGreen [MVP]
    Replies:
    5
    Views:
    2,082
    PA Bear [MS MVP]
    Feb 9, 2008
Loading...

Share This Page