views:

54

answers:

2

Hello.

I have to serialize & desserialize json data.

if the data type was XSD, I am able to create class by using XSDObjectGen.exe

But ,

the data type I have to serialize is 'JSON'.

Is there any good way to generate class for serialize & deserialize ?

+1  A: 

There is a JSONDataSerializer, but it is some obscure assembly. (Maybe the ASP.NET extensions?)

leppie
A: 

using System.Web.Script.Serialization;

...

JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

string payload = javaScriptSerializer.Serialize(myObject); //or string payload = javaScriptSerializer.Serialize(new object[] { myObject.Id });

Mark