0
我有門,看起來像一個列表:如何創建C#MVC JSON數組控制器
DoorId DoorName ControllerId ControllerName
------ -------- ------------ --------------
Door1 DoorOne C1 C1
Door2 DoorTwo C1 C1
Door3 DoorThree C2 C2
我需要格式化這樣的:
var doorsForSite = new[]
{
new { ControllerId ="C1",ControllerName="C1",IsChecked = "false",
Doors = new[]
{
new { DoorId="Door1",DoorName="DoorOne",Schedules = scheduleList},
new { DoorId="Door2",DoorName="DoorTwo",Schedules = scheduleList},
}
},
new { ControllerId ="C2",ControllerName="C2",IsChecked = "false",
Doors = new[]
{
new { DoorId= "Door3",DoorName="DoorThree",Schedules = scheduleList}
}
}
};
即通過ControllerId
是組和ControllerName
,然後構建Doors
陣列。
怎麼辦?
你們是不是該數組序列化到JSON或列表轉換成數組? –
將數組序列化爲Json – StrugglingCoder