I've got a class inherited from DynamicObject
. It contains all the properties stored in List<MyProperty>
:
public class MyObject : DynamicObject
{
public List<MyProperty> Properties { get; set; }
}
public class MyProperty
{
public string Name { get; set; }
public string Value { get; set; }
}
I want to serialize it to JSON using Newtonsoft Json. But after converting it I get an empty object: {}
. When I remove inheritance from DynamicObject, I get all my properties serialized as a JSON array. And that's exactly what I need. How can I serialize my class without removing that inheritance?