tags:

views:

83

answers:

2

It is any class in .NET 4.0 to serialize/de-serialize JSON data?? I find some 3rd party like JSON.NET, but want to know it is exist in .NET 4.0.

I find in MSDN, it introduce using Data Contracts to do, but it is for WCF, not WinForm/WPF

+1  A: 

There's the JavaScriptSerializer class (although you will need to reference the System.Web.Extensions assembly the class works perfectly fine in WinForms/WPF applications). Also even if the DataContractJsonSerializer class was designed for WCF it works fine in client applications.

Darin Dimitrov
+2  A: 

You can use the DataContractJsonSerializer class anywhere you want, it is just a .net class and is not limited to WCF. More info on how to use it here and here.

Ben Robinson
Thanks,MSDN said DataContractJsonSerializer class in Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll). However, VS2010 show error, cannot find DataContractJsonSerializer .
SilverNight
@TatMingThat's because, IIRC, pre .Net V4 it resides in System.ServiceModel.Web
Psytronic
Find that~ It about Target Framework problem, see : http://stackoverflow.com/questions/1825417/where-is-system-servicemodel-web-dll
SilverNight