I have the following Json:
{
"last_ts": "20161001154251",
"first_ts": "20061130072151",
"years": {
"2006": [
0,0,0,2,0,0,0,0,0,0,1,0
],
"2007": [
0,0,3,0,0,1,0,0,0,0,1,0
],
"2008": [.........],
.
.
.
}
}
I wanted to read each year's name and its corresponding array of numbers, I tried the following code:
JObject jObj = JObject.Parse(json);
var yearsA = jObj["years"];
foreach (var year in yearsA)
{
string yearStr = year. // code here to retrieve this year's name
foreach (var month in year.Children<JArray>().Children()) // loop thru each array value
{
int m = (int)month;
if(m > 0)
{
years.Add(yearStr);
break;
}
}
}
What I want now is just a way to get the name of the array, I tried lot of solutions but none worked for me.