Serialize / Deserialize Simple examples

Mar 24, 2009 at 7:42 AM
Hi All,

I want to look at some simlpe examples for serializing and deserializing objects like array, dataset, etc into JSON strings. Can anyone point me to some URL's or sample code. 

For array i tried as:

JavaScriptSerializer ser = new JavaScriptSerializer();
json = ser.Serialize(myArrayObject);

But it is giving error "A circular reference was detected while serializing an object of type 'System.Reflection.Module'"

Can anyone help?
Mar 24, 2009 at 9:14 AM
That is the .NET JSON serializer. My first suggestion would be to download Json.NET :-P
Mar 24, 2009 at 9:49 AM
Tried to do it with JSON.NEt even with the JSONConvert class. Below is my sample code:

ArrayList arr = new ArrayList();

string json = JSONConvert.Serialize(arr);

This gives an error: "JSONserializationException: Self referencing loop"

But when I try to fill the ArrayList with foreach loop, its working perfectly fine. Please help.
Sep 1, 2009 at 7:34 AM

 I use json Deserialize/Serialize DataTable,  The same problems with you!  How do you solve! can you tell me! thanks !

Sep 1, 2009 at 10:34 PM

Google is your friend...