You could use the DataContractJsonSerializer class that's part of the System.Runtime.Serialization assembly. Start by writing a model that will represent this entity:
public class MyModel
{
public decimal Demand { get; set; }
public decimal Supply { get; set; }
public DateTime Date { get; set; }
public string DateString { get; set; }
}
and then deserialize the JSON string to a list of this model:
string json = "[{ \"Demand\": 4422.45, \"Supply\": 17660, \"Date\": \"/Date(1236504600000)/\", \"DateString\": \"3 PM\" }, { \"Demand\": 4622.88, \"Supply\": 7794, \"Date\": \"/Date(1236522600000)/\", \"DateString\": \"8 PM\" }, { \"Demand\": 545.65, \"Supply\": 2767, \"Date\": \"/Date(1236583800000)/\", \"DateString\": \"1 PM\" }, { \"Demand\": 0, \"Supply\": 1, \"Date\": \"/Date(1236587400000)/\", \"DateString\": \"2 PM\" }]";
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<MyModel>));
using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
{
List<MyModel> models = (List<MyModel>)serializer.ReadObject(stream);
foreach (MyModel model in models)
{
// do something with the model here
Console.WriteLine(model.Date);
}
}
UPDATE:
It looks like you are using some prehistoric version of C# which doesn't support auto properties. In this case you will need a private field for each property:
public class MyModel
{
private decimal demand;
public decimal Demand
{
get { return this.demand; }
set { this.demand = value; }
}
private decimal supply;
public decimal Supply
{
get { return this.supply; }
set { this.supply = value; }
}
private DateTime date;
public DateTime Date
{
get { return this.date; }
set { this.supply = value; }
}
private string dateString;
public string DateString
{
get { return this.dateString; }
set { this.dateString = value; }
}
}