Deserialize JSON 2d array into list of objects?

Dec 29, 2009 at 2:53 AM
Edited Dec 29, 2009 at 6:29 PM

Sorry if this sort of question has been asked before, but I was hoping to deserialize the following:

 

{"name": "device", "values": [["2009-12-28T00:00:00Z", 12.5], ["2009-12-28T00:01:00Z", 14.6]]}

 

into an object structure that looks like:

 

class Device
{
    public string name;
    public List<DataPoint> values;
}

class DataPoint
{
    public DateTime timestamp;
    public float value;
}

 

Is there a good way to do this in JSON.net, perhaps using a custom contract resolver?

 

EDIT: I'm probably just going to end up doing LINQ to JSON for this, but I'll leave the question open in case anyone else needs a similar solution.