If I have a DataTable like this:
DataTable dt = new DataTable();
dt.Columns.Add("AccountNumber", typeof(string));
dt.Columns.Add("InstrumentType", typeof(string));
dt.Columns.Add("Symbol", typeof(string));
dt.Columns.Add("Quantity", typeof(int));
dt.Columns.Add("Exp", typeof(string));
dt.Columns.Add("Days", typeof(int));
dt.Columns.Add("Strike", typeof(double));
dt.Columns.Add("COP", typeof(string));
dt.Columns.Add("Action", typeof(string));
When serializing this DataTable using Json.NET, I would like to exclude certain columns, for example:
"AccountNumber", "COP", "Days", "Exp"
Is there a way to do this through a property? I believe for a class, you can use:
class Foo
{
[JsonIgnore]
public string COP{ get; set; }
}
Or do I have to write a custom converter?
public class MyDataTableConverter : JsonConverter
{
}
I can't find an example of how to do this?