2

In asp.net web api core 1.0 (I hope same as in asp.net web api 2.0), while serializing an object which is inherited from DynamicObject ignores the class's own declared properties.

public class Demo : DynamicObject
{
 // This property is ignore in api response
 public int Prop1 {get; set;}
}

Actual Json:

 {"DynamicProp1": "abc", "DynamicProp2" : 123 ... so on}

Expected Json:

{"Prop1": 123, "DynamicProp1": "abc", "DynamicProp2" : 123 ... so on}

Any suggestion?

Premchandra Singh
  • 14,156
  • 4
  • 31
  • 37

1 Answers1

1

Thanks, I got a solution

[DataContract]
public class Demo : DynamicObject
{
 // This property is ignore in api response
 [DataMember]   OR [JsonProperty]
 public int Prop1 {get; set;}
}

Original question.

Community
  • 1
  • 1
Premchandra Singh
  • 14,156
  • 4
  • 31
  • 37