【发布时间】:2015-03-23 16:21:25
【问题描述】:
我需要一个 .NET Web API,它允许从 JSON 对象输入字段,但不会将其序列化。我已经尝试过 [JsonIgnore] 注释,但是对于任何 json 对象,它都会完全忽略它,包括输入。
型号
public class MyModel{
[Key]
public int id {get; set;}
public string name {get; set;}
[JsonIgnore]
public Byte[] file {get; set;}
}
Json 输入
{
"name" : "MyName",
"image" : "akjsfjkha37842hui23yh23b"
}
期望的输出
{
"name" : "MyName"
}
【问题讨论】:
标签: .net json serialization asp.net-web-api annotations