[英]parent and child through json in asp.net mvc-hierarchy
sending list with name and value in json can be done with 可以在json中发送带有名称和值的列表
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 ? 但是当我想使用列表和外键为json设置hierarchy
结构时,parent的名称将为空,并且child完全成为parent的子代,为json实现parent / child的最佳方法是什么?
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# ? 它仅仅是父名称,如何在C#中实现?
new {
Employees =
{
new { firstName= "John", lastName= "Doe" },
new { firstName= "John2",lastName= "Doe2" },
new { firstName= "John3",lastName= "Doe3" }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.