This project has moved. For the latest updates, please go here.

DataSet deserialization

Jul 26, 2011 at 3:07 PM
Edited Jul 27, 2011 at 11:16 AM


I'm trying to find better way for DataSet (de)serialization. In our project we use BinaryFormatter, works fine but it's very slow. Finally I found JSON-ptoject, tried to do some test and I'm disappointed. I can serialize DataSet, but I cannot deserialize it back.

For testing I used our special class inherited from DataSet, it has insied about 107 tables with data.

At first I tried to use BSON:

JsonSerializer serializer = new JsonSerializer();
MemoryStream stream = new MemoryStream();

BsonWriter writer = new BsonWriter(stream);
serializer.Serialize(writer, testObject);

stream.Seek(0, SeekOrigin.Begin);

DataSet deserialized = serializer.Deserialize<DataSet>(reader);

At the end deserialixed object is DataSet with 1 DataTable, which has 0 DataTables inside. Stream.Position after desirialization is 44, stream.ToArray()[43] is 0.

The I tried to use JsonConvert:

string json = JsonConvert.SerializeObject(testObject, Formatting.Indented, new IsoDateTimeConverter());
DataSet deserialized = serializer.Deserialize<DataSet>(reader);

And I got an expetion: "Additional text found in JSON string after finishing deserializing object".

Ideas? Thanks for any advice.