.NET 3.5 version of code

M

Matty J

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
 
M

Matty J

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
 
J

Juan T. Llibre

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top