I'm trying to use ServiceStack.Text for deserializing a csv file containing custom headers.
var csv = "Col-1,Col-2" + Environment.NewLine +
"Val1,Val2" + Environment.NewLine +
"Val3,Val3" + Environment.NewLine;
public class Line
{
public string Col1 { get; set; }
public string Col2 { get; set; }
}
ServiceStack.Text.CsvConfig<Line>.CustomHeadersMap = new Dictionary<string, string> {
{"Col1", "Col-1"},
{"Col2", "Col-2"}
};
var r2 = ServiceStack.Text.CsvSerializer.DeserializeFromString<List<Line>>(csv);
Assert.That(r2.Count() == 2, "It should be 2 rows");
Assert.That(r2[0].Col1 == "Val1", "Expected Val1");
Assert.That(r2[0].Col2 == "Val2", "Expected Val2");
CustomHeadersMap is working when SerializeToString is used. But I can't get it working when using DeserializeFromString.