I am receiving data that looks like this from an online service provider:
{
name: \"test data\",
data: [
[ \"2017-05-31\", 2388.33 ],
[ \"2017-04
Rather than use tuples, I would create a class that is specific to the task. In this case your JSON data comes in as a list of lists of strings which is a bit awkward to deal with. One method would be to deserialise as List and then convert afterwards. For example, I would go with 3 classes like this:>
public class IntermediateTestData
{
public string Name;
public List> Data;
}
public class TestData
{
public string Name;
public IEnumerable Data;
}
public class TestDataItem
{
public DateTime Date { get; set; }
public double Value { get; set; }
}
Now deserialise like this:
var intermediate = JsonConvert.DeserializeObject(json);
var testData = new TestData
{
Name = intermediate.Name,
Data = intermediate.Data.Select(d => new TestDataItem
{
Date = DateTime.Parse(d[0]),
Value = double.Parse(d[1])
})
};