Best way to parse JSON data into a .NET object

What's the best way to parse JSON data into a .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.


Solution 1:

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

Solution 2:

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.

Solution 3:

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.