我目前有一个 WebGet 方法,它使用嵌套的 { d: } 元素正确返回 JSON,有没有办法删除它?
这是我的服务器端代码和定义 JSON 返回的类:
[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
public List<OpenOrderHeader> GetOpenOrders()
{
return (from OH in SCMENT.CustomerOrders
select new OpenOrderHeader()
{
CustomerID = OH.CustomerId,
OrderID = OH.CustomerOrderID,
OrderUniqueNumber = OH.CustomerOrderUniqueNumber,
OrderDateCreated = OH.CustomerOrderDateCreated,
OrderDateUpdated = OH.CustomerOrderDateUpdated,
OrderLocalOnline = OH.CustomerOrderOnlineOrLocal,
BranchID = (int)OH.CustomerOrderLocalBranchID,
OrderCurrency = OH.CustomerOrderCurrency,
OrderConversionRate = OH.CustomerOrderCurrencyConversionRate,
OrderStatus = OH.CustomerOrderStatus
}
).ToList();
}
班上:
public class OpenOrderHeader
{
public int CustomerID { get; set; }
public int OrderID { get; set; }
public int OrderUniqueNumber { get; set; }
public int NumberOfProductsOnOrder { get; set; }
public DateTime OrderDateCreated { get; set; }
public DateTime OrderDateUpdated { get; set; }
public string OrderLocalOnline { get; set; }
public int BranchID { get; set; }
public string PaymentMethod { get; set; }
public int OrderStatus { get; set; }
public string OrderCurrency { get; set; }
public decimal OrderConversionRate { get; set; }
public decimal SubTotalInclTax { get; set; }
public decimal SubTotalExclTax { get; set; }
public decimal DiscountInclTax { get; set; }
public decimal DiscountExclTax { get; set; }
public decimal ShippingInclTax { get; set; }
public decimal ShippingExclTax { get; set; }
public decimal PaymentFeeInclTax { get; set; }
public decimal PaymentFeeExclTax { get; set; }
}
JSON:
{
"d": [
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359696634387+0200)/",
"OrderDateUpdated": "/Date(1359703834253+0200)/",
"OrderID": 1,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 10,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359712050660+0200)/",
"OrderDateUpdated": "/Date(1359719250317+0200)/",
"OrderID": 2,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 11,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359713291023+0200)/",
"OrderDateUpdated": "/Date(1359720490673+0200)/",
"OrderID": 3,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 12,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359947946093+0200)/",
"OrderDateUpdated": "/Date(1359955145467+0200)/",
"OrderID": 4,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 13,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359948641833+0200)/",
"OrderDateUpdated": "/Date(1359955841153+0200)/",
"OrderID": 5,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 14,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359948752250+0200)/",
"OrderDateUpdated": "/Date(1359955951577+0200)/",
"OrderID": 6,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 15,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359948895973+0200)/",
"OrderDateUpdated": "/Date(1359956095290+0200)/",
"OrderID": 7,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 16,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "ZAR",
"OrderDateCreated": "/Date(1359949020693+0200)/",
"OrderDateUpdated": "/Date(1359956220013+0200)/",
"OrderID": 8,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 10,
"OrderUniqueNumber": 17,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
},
{
"__type": "OpenOrderHeader:#POS.Tracntrace.Member_Only.DAL.Models.Order",
"BranchID": -1,
"CustomerID": -1,
"DiscountExclTax": 0,
"DiscountInclTax": 0,
"NumberOfProductsOnOrder": 0,
"OrderConversionRate": 1,
"OrderCurrency": "USD",
"OrderDateCreated": "/Date(1359957893433+0200)/",
"OrderDateUpdated": "/Date(1359965238550+0200)/",
"OrderID": 9,
"OrderLocalOnline": "ONLINE",
"OrderStatus": 40,
"OrderUniqueNumber": 1,
"PaymentFeeExclTax": 0,
"PaymentFeeInclTax": 0,
"PaymentMethod": null,
"ShippingExclTax": 0,
"ShippingInclTax": 0,
"SubTotalExclTax": 0,
"SubTotalInclTax": 0
}
]
}