我有一个带有孩子的对象,我正在使用 JavaScriptSerializer 将其转换为 JSON。我正在使用 MVC 并在视图中使用 JavaScriptSerializer,如下所示:
@Html.Raw(serializer.Serialize(Model.Designs)
我的“设计”对象有子“DesignDeliveries”,但我需要从 JSON 字符串中删除这些,所以我尝试使用投影但无法获得我需要的格式
所以我的设计对象如下:
[{
"BookingDesignId": "e90e9500-0a6a-4d1b-a82a-fa7ca2d7c034",
"DesignName": "Design 600",
"Quantity": 100,
"DesignDeliveries": [{
"BookingId": "3706a896-3b8f-454f-acc8-6540441a3e4a",
"Quantity": 50,
"BookingDesignId": "e90e9500-0a6a-4d1b-a82a-fa7ca2d7c034",
"DepotId": "9"
},
{
"BookingId": "3706a896-3b8f-454f-acc8-6540441a3e4a",
"Quantity": 50,
"BookingDesignId": "e90e9500-0a6a-4d1b-a82a-fa7ca2d7c034",
"DepotId": "18"
}]
}];
但是,我需要:
[{
"BookingDesignId": "e90e9500-0a6a-4d1b-a82a-fa7ca2d7c034",
"DesignName": "Design 600",
"Quantity": 100,
"DesignDeliveries": [];
有谁知道如何实现这一目标?
提前致谢