【发布时间】:2014-06-25 05:14:54
【问题描述】:
在 WebAPI 中反序列化复杂类型让我非常痛苦。 数据包含在 c# 中作为属性名称在语法上无效的键。 如何翻译键名?
相关:Web API form-urlencoded binding to different property names
【问题讨论】:
标签: asp.net-web-api asp.net-web-api2
在 WebAPI 中反序列化复杂类型让我非常痛苦。 数据包含在 c# 中作为属性名称在语法上无效的键。 如何翻译键名?
相关:Web API form-urlencoded binding to different property names
【问题讨论】:
标签: asp.net-web-api asp.net-web-api2
您可以使用JSON.NET 的JsonProperty 来解决问题:
public class SomeModel {
[JsonProperty("YourCustomName")]
public string SomeProperty { get; set; }
}
【讨论】:
我编写了自己的url encoded object deserializer,它使用了JsonProperty 属性。然后我将它与自定义 modelbinder 一起使用。
【讨论】: