tags:

views:

6987

answers:

5

What's the best way to parse JSON date into and ASP.net object? I am trying to assist a coder friend of mine and he is trying to dump some data from a JSON string into a database using ASP.net. Are there any prebuilt scripts that would make this happen?

Thanks in advance to any help.

+5  A: 

The .NET Framework 3.5 has the JavaScriptSerializer class that can ease the deserialization. You can also use third party libraries like JSON.NET.

CMS
A: 

Thanks SO much for the fast reply!!

mhipp
+3  A: 

It should be noted that there is no such thing as an ASP.NET object (they are all CLR objects). Also, if you are using .NET 3.5, you probably don't need a third party library. The JavaScriptSerializer class can be used (just repeating what was mentioned before) but you also have access to the DataContractJsonSerializer, which offers a different model for mapping between CLR objects and JSON.

casperOne
A: 

Casper, thanks for the additional info!

mhipp
+6  A: 

Actually you should really look at the DataContractJsonSerializer as the JavaScriptSerializer was listed as Obsolete in the .NET 3.5 framework.

Admittedly ScottGu stated that it may have been a mistake and it may be reinstated in the future.

Slace