I am using Newtonsoft package in C#. I am trying to display all the items listed in a nested JSON array. I am having difficulty displaying the Name Jennifer Jones This is what the JSON String Looks Like
"responseDetails": {
"pageoffset": 0,
"size": 950,
},
"data": [
{
"id": 473145,
"name": "Class of 2000",
"doc_prog":
{
"responseDetails":
{
"pageoffset": 0,
"size": 1,
},
"data": [
{
"name": "Jennifer Jones"
}
]
},
This is what my class looks like
public respDetails responseDetails { get; set; }
public class respDetails
{
public int pageoffset { get; set; }
public string size { get; set; }
}
public List<datas> data { get; set; } // Top level class attribute
public class datas
{
public int id { get; set; }
public string name__v { get; set; }
public Programs doc_prog { get; set; }
public class Programs
{
public respDetails responseDetails { get; set; }
public class respDetails
{
public int pageoffset { get; set; }
public int size { get; set; }
}
public List<datasprogram> data { get; set; } // Top level class attribute
public class datasprogram
{
public string name { get; set; }
}
}
}
This is how I set up the for loop to list all the items in the array
var jRelated = JsonConvert.DeserializeObject<JDocsClass>(strRelated);
foreach (var num in jRelated.data)
{
Console.WriteLine(" Page Offset " + num.doc_prog.responseDetails.pageoffset.ToString() + " " + num.doc_prog.data.ToString() );
}
This is the Program Output
Page Offset 0 System.Collections.Generic.List`1[storeAPI.JCorrespondenceDocsClass+datas+Programs+datasprogram]
So Instead of displaying "Jennifer Jones", I am displaying "System.Collections.Generic.List...."
I appreciate any help pointing me in the right direction