I am consuming a RESTful Web service sending JSON, that I try to deserialize using HttpContent.ReadAsAsync<T>
. The type I try to deserialize to declares a property that returns an IEnumerable containing an interface type. This code snippet demonstrates the kind of type I'm trying to deserialize to:
public class Data
{
public IEnumerable<IChild> Children { get; set; };
}
The problem is that Newtonsoft.Json, underlying HttpContent.ReadAsAsync<T>
doesn't understand how to deserialize objects of type IChild
, the latter being an interface. How can I specify to Newtonsoft.Json how to deserialize IChild to a concrete type?