Below is my JSON structure:
{
"status": "success",
"data": {
"MyValues": [
[
"2018-09-06T09:15:00+0530",
1030,
1038.75,
1017.2,
1030.9,
542542
],
[
"2018-09-07T09:15:00+0530",
1032.7,
1035.45,
1015.5,
1025.35,
410461
]
]
}
}
I am using Newtonsoft JSON. To make it strongly typed, I created below classes, considering JSON structure:
class MyValues
{
public DateTime TimeStamp { get; set; }
public decimal First { get; set; }
public decimal Second { get; set; }
public decimal Third { get; set; }
public decimal Fourth { get; set; }
public decimal Fifth { get; set; }
}
class Data
{
public MyValues[] MyValues { get; set; }
}
class MyData
{
public string Status { get; set; }
public Data Data { get; set; }
}
Finally, Below is the code I have written. It reads the above json object from jd.txt file and tries to parse it:
using (StreamReader file = File.OpenText(@"jd.txt"))
{
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
MyData MyData = (MyData)serializer.Deserialize(file, typeof(MyData));
}
When I run above code, I see MyData.Data.MyValues null. I am unable to figure out the problem.
Kindly guide me to solve the problem