SerializableDataTable is a library providing an abstraction class that allows you to serialize and deserialize data to and from a DataTable
instance.
If you have any issues or feedback, please file an issue here in Github. We'd love to have you help by contributing code for new features, optimization to the existing codebase, ideas for future releases, or fixes!
- Initial release
Refer to the Test
project for exercising the library. This is example is using the NuGet package SerializationHelper for simplicity purposes.
using System.Data;
using SerializableDataTables;
using SerializationHelper;
// Create your DataTable and columns
DataTable dt1 = new DataTable();
dt1.Columns.Add(new DataColumn { ... });
// Create your DataRows
DataRow row = dt1.NewRow();
row["[name]"] = "[value]";
dt1.Rows.Add(row);
string json = Serializer.SerializeJson(SerializableDataTable.FromDataTable(dt), true);
Console.WriteLine("JSON: " + Environment.NewLine + json + Environment.NewLine);
DataTable dt2 = Serializer.DeserializeJson<SerializableDataTable>(json).ToDataTable();
This library supports the following DataTable
value types: string
, Int32
, Int64
, decimal
, double
, float
, bool
, DateTime
, DateTimeOffset
, byte
, byte[]
, char
, Guid
.
The library currently does not support arrays or nested objects.
Refer to CHANGELOG.md for version history.