-1
我尝试实现ASP.NET MVC 5 WebAPI修补程序。但是int值和枚举存在一个问题。 JSON反序列化“思考”,这是更好的转换诠释为长,所以是因为在我int属性我recive总是0 ...c#JSONPatch不与int和枚举工作
因此,我发现“Microsoft.AspNet.JsonPatch.JsonPatchDocument”(还有很多人疗法)
接着的问题是,我recive八方通空在我的模型
public async Task<IHttpActionResult> Patch(int id, [FromBody] Microsoft.AspNet.JsonPatch.JsonPatchDocument<Customer> model)
{
//model is allways == null
}
我使用邮递员补丁派在车身>原始JSON。标题是应用程序/ json。
我不明白为什么模型为null ...我需要在WebApiConfig上做任何事情?
尽管我试图实现一个自定义JsonConverter,但问题是我有很多枚举类型,我需要为每个枚举创建一个?我尝试sothing这样的:
public class Int32EnumConverter<T> : JsonConverter
但问题是,你需要实现这个WebApiConfig.cs:
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new Int32EnumConverter<[I NEED HEAR Dynamic Enum Types>>);
没有任何人帮我?谢谢!
为什么不直接使用Json.net而不需要注册其他序列化程序呢? – Marco
因为JSON.net在http patch deserialize int long ... – rockxl1
我仍然无法看到问题是什么。 – Marco