Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

.NET 3.5 version of code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matty J - 17 May 2008 02:28 GMT
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 - 17 May 2008 04:33 GMT
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/
======================================
> Hi
>
[quoted text clipped - 9 lines]
> Cheers
> Matt
Matty J - 20 May 2008 17:18 GMT
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 - 20 May 2008 17:50 GMT
re:
!> obsolete

Obsolete ?

Even ScottGu wonders why :

http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-ex
tension-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/
======================================
> Thanks Juan.
>
[quoted text clipped - 10 lines]
> Cheers
> Matt
Matty J - 21 May 2008 22:00 GMT
Great, thanks Juan, that's what I needed to know.
Cheers
Matt

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.