I'm learning C # and am having some difficulty passing a multidimensional json to an object doing a deserialize. I'm not sure how to resolve this.
See my json
string json2 = @"[
{
firstName: ""joao"",
lastName: ""silva"",
dateOfBirth:
{
year: ""1990"",
month: ""01"",
day: ""01""
}
},
{
firstName: ""carla"",
lastName: ""dias"",
dateOfBirth:
{
year: ""2000"",
month: ""02"",
day: ""02""
}
}
]";
Now the classes I created (actually it was C # with special paste)
public class Class1
{
public string firstName { get; set; }
public string lastName { get; set; }
public Dateofbirth dateOfBirth { get; set; }
}
public class Dateofbirth
{
public string year { get; set; }
public string month { get; set; }
public string day { get; set; }
}
public class Rootobject
{
public Class1[] Property1 { get; set; }
}
Now I'm trying to do deserialize
List<Rootobject> listLad = JsonConvert.DeserializeObject<List<Rootobject>>(json2);
Response.Write(listLad[0].Property1[0].lastName);
But it gives error (I'm very accustomed to php)