json:
[{
"PersonsTable":[
{"id":293,"firstname":"jos","lastname":"don"},
{"id":1861,"firstname":"jef","lastname":"dan"},
{"id":1896,"firstname":"janine","lastname":"din"}]
}]
code:
List<Person> persons = new List<Person>();
dynamic dynObj = JsonConvert.DeserializeObject(response);
foreach (var data in dynObj.PersonsTable)
{
Person p = new Person(data.id, data.firstname, data.lastname);
persons.Add(p);
}
Object:
public class Person
{
public Person ()
{
}
public Person (string id, string firstname, string lastname)
{
this.id= id;
this.firstname = firstname;
this.lastname = lastname;
}
public string id{ get; set; }
public string firstname{ get; set; }
public string lastname{ get; set; }
}
I want to put the data under "PersonsTable" into the person list. I have tried to achieve this with serialize and dynamic variables but i always get a weird error "Missing compiler required member, 'microsoft.CSharp.RUntimeBinder.CSharpArgumentINfo.Create'"..
The NuGet package itself i can't install because my project runs in .Net 3.5 (for some reason).
Can someone help me with my problem? Are there other ways to get a list of persons in result?