I have a custom collection (implements IList) which has some custom properties as shown below:
class FooCollection : IList<Foo> {
private List<Foo> _foos = new List<Foo>();
public string Bar { get; set; }
//Implement IList, ICollection and IEnumerable members...
}
When I serialize, I use the following code:
JsonSerializerSettings jss = new JsonSerializerSettings() {
TypeNameHandling = TypeNameHandling.Auto
};
string serializedCollection = JsonConvert.SerializeObject( value , jss );
It serializes and deserializes all the collection items properly; however, any extra properties in the FooCollection
class are not taken into account.
Is there anyway to include them in the serialization?
Foo[]
as the type in the surrogate - I had to use anIEnumerable<Foo>
– Traceetracer