i have 2 class:
class Employee
{
string name;
string age;
}
class Departments
{
string branch;
Employee A;
}
Declare new list:
List<Departments> lstDp = new List<Departments>();
after get/set and Add Employee into the list ... i have a LIST of Departments include Employee info. And then:
string json = JsonConvert.SerializeObject(lstDp, Newtonsoft.Json.Formatting.Indented);
but the output JSON string only contain element "branch". What's wrong with this? I want the output like this:
[
{
"branch": "NY",
"Employee": {
"name": "John Smith",
"age": "29",
}
}
]
Employeestring in the output. It will beA3)Ais not a list. It is a single employee.