在asp.net web api core 1.0 (我希望与asp.net web api 2.0相同)中,序列化从DynamicObject继承的对象时会忽略类自己声明的属性。
public class Demo : DynamicObject
{
// This property is ignore in api response
public int Prop1 {get; set;}
}
实际Json: {"DynamicProp1": "abc", "DynamicProp2" : 123 ... so on}
将Json:
{"Prop1": 123, "DynamicProp1": "abc", "DynamicProp2" : 123 ... so on}
任何建议吗?
谢谢,我有办法了
[DataContract]
public class Demo : DynamicObject
{
// This property is ignore in api response
[DataMember] OR [JsonProperty]
public int Prop1 {get; set;}
}
原始问题。