sending list with name and value in json can be done with
public ActionResult Index()
{
return Json(new { firstName= "John",lastName= "Doe" });
}
but when i want to have hierarchy
structure for json using list and foreign key , name of parent will be empty and child become child of parent exactly , what is the best way to implement parent/child for json ?
Update: {
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
employe is parent and has no value. it is just name of parent , how implement in C# ?
new {
Employees =
{
new { firstName= "John", lastName= "Doe" },
new { firstName= "John2",lastName= "Doe2" },
new { firstName= "John3",lastName= "Doe3" }
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.